change WUSD payment to USDC

This commit is contained in:
2025-12-24 16:41:26 +08:00
parent d2e9377f78
commit e21ee7a5df
160 changed files with 6038 additions and 4050 deletions

View File

@@ -34,6 +34,11 @@ async function main() {
console.log(` ${i + 1}. ${v.name} (${v.symbol}): ${v.address}`);
});
// 读取USDC配置
const usdcConfig = JSON.parse(fs.readFileSync("./deployments-usdc-config.json", "utf8"));
const usdcAddress = usdcConfig.contracts.USDC.address;
console.log("\nUSDC地址:", usdcAddress);
// 获取合约实例
const priceFeed = await ethers.getContractAt("YTPriceFeed", priceFeedAddress);
const vault = await ethers.getContractAt("YTVault", vaultAddress);
@@ -42,25 +47,26 @@ async function main() {
console.log("\n===== 2. 添加到白名单 =====");
// 配置参数(可根据需要调整)
// 注意:总权重 = 4000 + 3000 + 2000 = 9000
// 注意:总权重 = 4000 + 3000 + 2000 + 1000 = 10000
const whitelistParams = [
{
weight: 4000, // 4000/9000 = 44.44%
weight: 4000, // 4000/10000 = 40%
maxUsdyAmount: ethers.parseEther("45000000"), // 4500万
isStable: false
},
{
weight: 3000, // 3000/9000 = 33.33%
weight: 3000, // 3000/10000 = 30%
maxUsdyAmount: ethers.parseEther("35000000"), // 3500万
isStable: false
},
{
weight: 2000, // 2000/9000 = 22.22%
weight: 2000, // 2000/10000 = 20%
maxUsdyAmount: ethers.parseEther("25000000"), // 2500万
isStable: false
}
];
// 添加YT代币到白名单
for (let i = 0; i < vaults.length && i < whitelistParams.length; i++) {
const v = vaults[i];
const params = whitelistParams[i];
@@ -81,8 +87,29 @@ async function main() {
console.log(" ✅ 是否稳定币:", params.isStable);
}
// ==================== 3. 设置价格 ====================
console.log("\n===== 3. 设置价格 =====");
// 添加USDC到白名单
console.log("\n添加 USDC 到白名单...");
const usdcParams = {
weight: 1000, // 1000/10000 = 10%
maxUsdyAmount: ethers.parseUnits("30000000", 6), // 3000万 USDC
isStable: true // USDC是稳定币
};
const usdcTx = await vault.setWhitelistedToken(
usdcAddress,
6, // Todo USDC在Arbitrum测试网是6位精度
usdcParams.weight,
usdcParams.maxUsdyAmount,
usdcParams.isStable
);
await usdcTx.wait();
console.log(" ✅ 权重:", usdcParams.weight);
console.log(" ✅ 最大USDY:", ethers.formatEther(usdcParams.maxUsdyAmount));
console.log(" ✅ 是否稳定币:", usdcParams.isStable);
// ==================== 3. 设置YT价格 ====================
console.log("\n===== 3. 设置YT价格 =====");
for (const v of vaults) {
console.log(`\n设置 ${v.name} (${v.symbol}) 价格...`);
@@ -96,23 +123,13 @@ async function main() {
);
await tx.wait();
console.log(" ✅ 价格已设置:", ethers.formatUnits(price, 30), "(精度1e30)");
console.log(" ✅ YT价格已设置:", ethers.formatUnits(price, 30), "(精度1e30)");
}
// ==================== 4. 设置WUSD价格来源 ====================
console.log("\n===== 4. 设置WUSD价格来源 =====");
console.log("\n✅ USDC价格从Chainlink自动获取无需手动设置");
// 使用第一个vault作为WUSD价格来源
const firstVault = vaults[0];
console.log("设置WUSD价格来源为:", firstVault.name, firstVault.address);
const tx = await priceFeed.setWusdPriceSource(firstVault.address);
await tx.wait();
console.log(" ✅ WUSD价格来源已设置");
// ==================== 5. 验证配置 ====================
console.log("\n===== 5. 验证配置 =====");
// ==================== 4. 验证配置 ====================
console.log("\n===== 4. 验证配置 =====");
for (const v of vaults) {
const isWhitelisted = await vault.whitelistedTokens(v.address);
@@ -125,33 +142,60 @@ async function main() {
console.log(" 价格:", ethers.formatUnits(price, 30));
}
// 验证USDC
const usdcWhitelisted = await vault.whitelistedTokens(usdcAddress);
const usdcWeight = await vault.tokenWeights(usdcAddress);
const usdcIsStable = await vault.stableTokens(usdcAddress);
const usdcPrice = await priceFeed.getPrice(usdcAddress, true);
console.log("\nUSDC:");
console.log(" 白名单:", usdcWhitelisted ? "✅" : "❌");
console.log(" 权重:", usdcWeight.toString());
console.log(" 价格:", ethers.formatUnits(usdcPrice, 30), "(从Chainlink获取)");
console.log(" 稳定币:", usdcIsStable ? "✅" : "❌");
const totalWeight = await vault.totalTokenWeights();
console.log("\n总权重:", totalWeight.toString());
const wusdPriceSource = await priceFeed.wusdPriceSource();
console.log("WUSD价格来源:", wusdPriceSource);
// ==================== 6. 输出摘要 ====================
// ==================== 5. 输出摘要 ====================
console.log("\n===== 配置完成!=====");
console.log("\n✅ 已添加", vaults.length, "个vault到白名单");
console.log("✅ 已为所有vault设置初始价格");
console.log("✅ 已设置WUSD价格来源");
console.log("\n✅ 已添加", vaults.length, "个YT代币到白名单");
console.log("✅ 已添加 USDC 到白名单(稳定币)");
console.log("✅ 已为所有YT代币设置初始价格");
console.log("✅ USDC价格从Chainlink自动更新");
console.log("\n📋 池子组成: USDC/YT-A/YT-B/YT-C");
console.log(" • USDC: 10% (稳定币, 手续费0.04%)");
console.log(" • YT-A: 40% (YT代币, 手续费0.3%)");
console.log(" • YT-B: 30% (YT代币, 手续费0.3%)");
console.log(" • YT-C: 20% (YT代币, 手续费0.3%)");
console.log("\n💡 系统已就绪,可以开始使用!");
// 保存配置信息
const configInfo = {
timestamp: new Date().toISOString(),
operator: deployer.address,
whitelistedVaults: vaults.map((v: any, i: number) => ({
name: v.name,
symbol: v.symbol,
address: v.address,
weight: whitelistParams[i]?.weight || 0,
maxUsdyAmount: whitelistParams[i]?.maxUsdyAmount.toString() || "0",
price: v.ytPrice
})),
whitelistedTokens: {
ytTokens: vaults.map((v: any, i: number) => ({
name: v.name,
symbol: v.symbol,
address: v.address,
weight: whitelistParams[i]?.weight || 0,
maxUsdyAmount: whitelistParams[i]?.maxUsdyAmount.toString() || "0",
price: v.ytPrice,
isStable: false
})),
usdc: {
name: "USDC",
symbol: "USDC",
address: usdcAddress,
weight: usdcParams.weight,
maxUsdyAmount: usdcParams.maxUsdyAmount.toString(),
priceSource: "Chainlink (自动)",
isStable: true
}
},
totalWeight: totalWeight.toString(),
wusdPriceSource: wusdPriceSource
poolComposition: "USDC/YT-A/YT-B/YT-C"
};
fs.writeFileSync(