fix contract

This commit is contained in:
2026-01-12 14:33:16 +08:00
parent a18b9a42e4
commit d56f83726b
70 changed files with 1988 additions and 142 deletions

View File

@@ -108,6 +108,15 @@ async function main() {
console.log(" ✅ Vault地址:", vaultAddress);
console.log(" ✅ Vault索引:", index.toString());
// 配置价格过期阈值
const vault = await ethers.getContractAt("YTAssetVault", vaultAddress);
const network = await ethers.provider.getNetwork();
const isTestnet = network.chainId === 97n || network.chainId === 11155111n; // BSC测试网或Sepolia
const priceStalenesThreshold = isTestnet ? 86400 : 3600; // 测试网24小时主网1小时
await factory.setPriceStalenessThreshold(vaultAddress, priceStalenesThreshold);
console.log(" ✅ 价格过期阈值:", priceStalenesThreshold, "秒", `(${priceStalenesThreshold / 3600}小时)`);
createdVaults.push({
name: params.name,

View File

@@ -65,9 +65,11 @@ async function main() {
console.log(" ✅ 添加YTPoolManager");
// 配置YTLPToken权限
console.log("配置YTLPToken minter权限...");
console.log("配置YTLPToken权限...");
await ytLP.setMinter(poolManagerAddress, true);
console.log(" ✅ 设置YTPoolManager为minter");
await ytLP.setPoolManager(poolManagerAddress);
console.log(" ✅ 设置PoolManager用于转账时继承冷却时间");
// 配置Vault权限
console.log("配置YTVault权限...");
@@ -87,6 +89,15 @@ async function main() {
// USDC价格从Chainlink获取无需设置价格来源
console.log("✅ USDC价格从Chainlink自动获取");
// 根据网络设置价格过期阈值
const network = await ethers.provider.getNetwork();
const isTestnet = network.chainId === 97n || network.chainId === 11155111n; // BSC测试网或Sepolia
const priceStalenesThreshold = isTestnet ? 86400 : 3600; // 测试网24小时主网1小时
console.log("设置价格过期阈值...");
await priceFeed.setPriceStalenessThreshold(priceStalenesThreshold);
console.log(" ✅ 阈值:", priceStalenesThreshold, "秒", `(${priceStalenesThreshold / 3600}小时)`);
// 设置keeper权限默认设置deployer为keeper
console.log("设置Keeper权限...");
await priceFeed.setKeeper(deployer.address, true);
@@ -121,6 +132,7 @@ async function main() {
console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
console.log("✅ USDY vaults: YTVault, YTPoolManager");
console.log("✅ YTLPToken minter: YTPoolManager");
console.log("✅ YTLPToken poolManager: YTPoolManager (冷却时间保护)");
console.log("✅ YTVault poolManager: YTPoolManager");
console.log("✅ YTVault swapper: YTRewardRouter");
console.log("✅ YTPoolManager handler: YTRewardRouter");
@@ -145,6 +157,7 @@ async function main() {
permissions: {
usdyVaults: [vaultAddress, poolManagerAddress],
ytlpMinters: [poolManagerAddress],
ytlpPoolManager: poolManagerAddress,
vaultPoolManager: poolManagerAddress,
vaultSwappers: [routerAddress],
poolManagerHandlers: [routerAddress],

View File

@@ -79,6 +79,13 @@ async function main() {
console.log("✅ LendingPriceFeed Implementation:", lendingPriceFeedImplAddress);
deployments.lendingPriceFeedImpl = lendingPriceFeedImplAddress;
// 根据网络设置价格过期阈值(必须在验证价格之前设置)
const isTestnet = network.chainId === 97n || network.chainId === 11155111n; // BSC测试网或Sepolia
const priceStalenesThreshold = isTestnet ? 86400 : 3600; // 测试网24小时主网1小时
const setThresholdTx = await lendingPriceFeed.setPriceStalenessThreshold(priceStalenesThreshold);
await setThresholdTx.wait(); // 等待交易确认
console.log("✅ 价格过期阈值已设置:", priceStalenesThreshold, "秒", `(${priceStalenesThreshold / 3600}小时)`);
// 验证价格获取
const usdcPrice = await lendingPriceFeed.getPrice(USDC_ADDRESS);
console.log("✅ USDC 价格 (1e30 精度):", usdcPrice.toString());

View File

@@ -38,6 +38,17 @@ async function main() {
console.log(" USDC Address:", deployments.usdcAddress);
console.log(" USDC Price Feed:", deployments.usdcPriceFeed, "\n");
// ========== 配置 LendingPriceFeed 价格过期阈值 ==========
console.log("⚙️ 配置 LendingPriceFeed 价格过期阈值");
const lendingPriceFeed = await ethers.getContractAt("LendingPriceFeed", deployments.lendingPriceFeed);
// 根据网络设置价格过期阈值
const isTestnet = network.chainId === 97n || network.chainId === 11155111n; // BSC测试网或Sepolia
const priceStalenesThreshold = isTestnet ? 86400 : 3600; // 测试网24小时主网1小时
await lendingPriceFeed.setPriceStalenessThreshold(priceStalenesThreshold);
console.log(" ✅ 阈值:", priceStalenesThreshold, "秒", `(${priceStalenesThreshold / 3600}小时)\n`);
// ========== 读取 YT Vault 部署信息 ==========
const vaultDeploymentsPath = path.join(__dirname, "../../deployments-vault-system.json");
if (!fs.existsSync(vaultDeploymentsPath)) {

View File

@@ -0,0 +1,8 @@
npx hardhat run scripts/deploy/01-prepareUSDC.ts --network bscTestnet
npx hardhat run scripts/deploy/02-deployYTLp.ts --network bscTestnet
npx hardhat run scripts/deploy/03-deployAsset.ts --network bscTestnet
npx hardhat run scripts/deploy/04-createVault.ts --network bscTestnet
npx hardhat run scripts/deploy/05-configureYTLp.ts --network bscTestnet
npx hardhat run scripts/deploy/06-addVaultToWhitelist.ts --network bscTestnet
npx hardhat run scripts/deploy/07-deployLending.ts --network bscTestnet
npx hardhat run scripts/deploy/08-configureLending.ts --network bscTestnet

View File

@@ -1,46 +0,0 @@
import { ethers } from "hardhat";
async function generateSetAllowedBrokerCalldata() {
// 合约地址
const vaultAddress = "0x82b6b970711C07FE98Fa60C9d80f1be5B9fa32FF";
// 参数
const brokerHash = "0xad7c5bef027816a800da1736444fb58a807ef4c9603b7848673f7e3a68eb14a5";
const allowed = true; // 添加 broker
// 定义函数的 ABI
const functionAbi = [
"function setAllowedBroker(bytes32 _brokerHash, bool _allowed)"
];
// 创建 Interface 实例
const iface = new ethers.Interface(functionAbi);
// 编码函数调用数据
const calldata = iface.encodeFunctionData("setAllowedBroker", [
brokerHash,
allowed
]);
console.log("=".repeat(80));
console.log("Vault 合约地址:", vaultAddress);
console.log("函数名称: setAllowedBroker");
console.log("参数:");
console.log(" - brokerHash:", brokerHash);
console.log(" - allowed:", allowed);
console.log("=".repeat(80));
console.log("生成的 Calldata:");
console.log(calldata);
console.log("=".repeat(80));
return calldata;
}
// 执行函数
generateSetAllowedBrokerCalldata()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});