Initial Commit
This commit is contained in:
28
scripts/advanceTime.js
Normal file
28
scripts/advanceTime.js
Normal file
@@ -0,0 +1,28 @@
|
||||
const { ethers, JsonRpcProvider } = require('ethers');
|
||||
|
||||
// Define the Tenderly provider with your Tenderly fork RPC URL
|
||||
// const provider = new ethers.providers.JsonRpcProvider("https://rpc.tenderly.co/fork/c3c1b1c6-3139-4682-80ef-992caf6c59d8");
|
||||
const provider = new JsonRpcProvider('https://virtual.binance.rpc.tenderly.co/bd4ca4c1-0512-47bf-9674-6f509e9ad7fc');
|
||||
|
||||
// Define the number of seconds to advance the time
|
||||
const timeInSeconds = 24 * 60 * 60 * 120; // 24 hours in seconds
|
||||
|
||||
async function advanceTime() {
|
||||
try {
|
||||
// Convert the time into a hex-encoded value
|
||||
const params = [ethers.toQuantity(timeInSeconds)];
|
||||
|
||||
// Send the `evm_increaseTime` RPC call to the Tenderly fork
|
||||
await provider.send("evm_increaseTime", params);
|
||||
|
||||
// Send the `evm_mine` RPC call to mine the next block
|
||||
await provider.send("evm_mine", []);
|
||||
|
||||
console.log(`Time advanced by ${timeInSeconds} seconds (24 hours).`);
|
||||
} catch (error) {
|
||||
console.error("Failed to advance time:", error);
|
||||
}
|
||||
}
|
||||
|
||||
// Call the function to advance time
|
||||
// advanceTime();
|
||||
149
scripts/createStakes.js
Normal file
149
scripts/createStakes.js
Normal file
@@ -0,0 +1,149 @@
|
||||
const { ethers } = require("hardhat");
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
async function main() {
|
||||
// Load deployed addresses
|
||||
const deployedAddressesPath = path.join(__dirname, "deployedAddresses.json");
|
||||
const deployedAddresses = JSON.parse(fs.readFileSync(deployedAddressesPath, "utf8"));
|
||||
|
||||
// Extract the proxy address
|
||||
const proxyAddress = deployedAddresses.proxyAddress; // Adjust the key if named differently
|
||||
|
||||
// Get the Contract ABI and connect to the proxy
|
||||
// Replace 'PacaFinanceWithBoostAndSchedule' with your contract name if different
|
||||
const PacaContract = await ethers.getContractFactory("PacaFinanceWithBoostAndSchedule");
|
||||
const proxy = await PacaContract.attach(proxyAddress);
|
||||
|
||||
// Address to impersonate
|
||||
const impersonateAddress = "0xbf12D3b827a230F7390EbCc9b83b289FdC98ba81";
|
||||
|
||||
// Impersonate account
|
||||
await network.provider.request({
|
||||
method: "hardhat_impersonateAccount",
|
||||
params: [impersonateAddress]
|
||||
});
|
||||
|
||||
// Get impersonated signer
|
||||
const impersonatedSigner = await ethers.getSigner(impersonateAddress);
|
||||
|
||||
// Prepare stake inputs
|
||||
const stakeInputs = [
|
||||
{
|
||||
user: "0x1234567890123456789012345678901234567890", // Replace with a test address
|
||||
amount: ethers.parseEther("100"), // 100 tokens
|
||||
unlockTime: Math.floor(Date.now() / 1000) + 86400 * 30, // 30 days from now
|
||||
dailyRewardRate: 5, // Reward rate
|
||||
},
|
||||
{
|
||||
user: "0x1234567890123456789012345678901234567890", // Same user for multiple stakes
|
||||
amount: ethers.parseEther("200"), // 200 tokens
|
||||
unlockTime: Math.floor(Date.now() / 1000) + 86400 * 60, // 60 days from now
|
||||
dailyRewardRate: 10, // Reward rate
|
||||
},
|
||||
{
|
||||
user: "0x1234567890123456789012345678901234567890", // Same user for multiple stakes
|
||||
amount: ethers.parseEther("200"), // 200 tokens
|
||||
unlockTime: Math.floor(Date.now() / 1000) + 86400 * 60, // 60 days from now
|
||||
dailyRewardRate: 10, // Reward rate
|
||||
},
|
||||
{
|
||||
user: "0x1234567890123456789012345678901234567890", // Same user for multiple stakes
|
||||
amount: ethers.parseEther("200"), // 200 tokens
|
||||
unlockTime: Math.floor(Date.now() / 1000) + 86400 * 60, // 60 days from now
|
||||
dailyRewardRate: 10, // Reward rate
|
||||
},
|
||||
{
|
||||
user: "0x1234567890123456789012345678901234567890", // Same user for multiple stakes
|
||||
amount: ethers.parseEther("200"), // 200 tokens
|
||||
unlockTime: Math.floor(Date.now() / 1000) + 86400 * 60, // 60 days from now
|
||||
dailyRewardRate: 10, // Reward rate
|
||||
},
|
||||
|
||||
{
|
||||
user: "0x1234567890123456789012345678901234567890", // Same user for multiple stakes
|
||||
amount: ethers.parseEther("200"), // 200 tokens
|
||||
unlockTime: Math.floor(Date.now() / 1000) + 86400 * 60, // 60 days from now
|
||||
dailyRewardRate: 10, // Reward rate
|
||||
},
|
||||
{
|
||||
user: "0x1234567890123456789012345678901234567890", // Same user for multiple stakes
|
||||
amount: ethers.parseEther("200"), // 200 tokens
|
||||
unlockTime: Math.floor(Date.now() / 1000) + 86400 * 60, // 60 days from now
|
||||
dailyRewardRate: 10, // Reward rate
|
||||
},
|
||||
{
|
||||
user: "0x1234567890123456789012345678901234567890", // Same user for multiple stakes
|
||||
amount: ethers.parseEther("200"), // 200 tokens
|
||||
unlockTime: Math.floor(Date.now() / 1000) + 86400 * 60, // 60 days from now
|
||||
dailyRewardRate: 10, // Reward rate
|
||||
},
|
||||
|
||||
{
|
||||
user: "0x1234567890123456789012345678901234567890", // Same user for multiple stakes
|
||||
amount: ethers.parseEther("200"), // 200 tokens
|
||||
unlockTime: Math.floor(Date.now() / 1000) + 86400 * 60, // 60 days from now
|
||||
dailyRewardRate: 10, // Reward rate
|
||||
},
|
||||
{
|
||||
user: "0x1234567890123456789012345678901234567890", // Same user for multiple stakes
|
||||
amount: ethers.parseEther("200"), // 200 tokens
|
||||
unlockTime: Math.floor(Date.now() / 1000) + 86400 * 60, // 60 days from now
|
||||
dailyRewardRate: 10, // Reward rate
|
||||
},
|
||||
{
|
||||
user: "0x1234567890123456789012345678901234567890", // Same user for multiple stakes
|
||||
amount: ethers.parseEther("200"), // 200 tokens
|
||||
unlockTime: Math.floor(Date.now() / 1000) + 86400 * 60, // 60 days from now
|
||||
dailyRewardRate: 10, // Reward rate
|
||||
},
|
||||
|
||||
{
|
||||
user: "0x1234567890123456789012345678901234567890", // Same user for multiple stakes
|
||||
amount: ethers.parseEther("200"), // 200 tokens
|
||||
unlockTime: Math.floor(Date.now() / 1000) + 86400 * 60, // 60 days from now
|
||||
dailyRewardRate: 10, // Reward rate
|
||||
},
|
||||
{
|
||||
user: "0x1234567890123456789012345678901234567890", // Same user for multiple stakes
|
||||
amount: ethers.parseEther("200"), // 200 tokens
|
||||
unlockTime: Math.floor(Date.now() / 1000) + 86400 * 60, // 60 days from now
|
||||
dailyRewardRate: 10, // Reward rate
|
||||
},
|
||||
{
|
||||
user: "0x1234567890123456789012345678901234567890", // Same user for multiple stakes
|
||||
amount: ethers.parseEther("200"), // 200 tokens
|
||||
unlockTime: Math.floor(Date.now() / 1000) + 86400 * 60, // 60 days from now
|
||||
dailyRewardRate: 10, // Reward rate
|
||||
},
|
||||
{
|
||||
user: "0x1234567890123456789012345678901234567890", // Same user for multiple stakes
|
||||
amount: ethers.parseEther("200"), // 200 tokens
|
||||
unlockTime: Math.floor(Date.now() / 1000) + 86400 * 60, // 60 days from now
|
||||
dailyRewardRate: 10, // Reward rate
|
||||
},
|
||||
{
|
||||
user: "0x1234567890123456789012345678901234567890", // Same user for multiple stakes
|
||||
amount: ethers.parseEther("200"), // 200 tokens
|
||||
unlockTime: Math.floor(Date.now() / 1000) + 86400 * 60, // 60 days from now
|
||||
dailyRewardRate: 10, // Reward rate
|
||||
},
|
||||
|
||||
];
|
||||
|
||||
// Call the createStakes function
|
||||
// console.log("Sending transaction to create stakes from impersonated address...");
|
||||
// const tx = await proxy.connect(impersonatedSigner).createStakes(stakeInputs);
|
||||
// await tx.wait();
|
||||
|
||||
// console.log("Stakes created successfully!");
|
||||
const tx = await proxy.connect(impersonatedSigner).getStakes("0xfe5FD43b5DD5E9dA362901C5B24EF7aEdC3914B0");
|
||||
// await tx.wait();
|
||||
console.log(tx);
|
||||
|
||||
}
|
||||
|
||||
main().catch((error) => {
|
||||
console.error(error);
|
||||
process.exitCode = 1;
|
||||
});
|
||||
91
scripts/deploy.js
Normal file
91
scripts/deploy.js
Normal file
@@ -0,0 +1,91 @@
|
||||
const { ethers, upgrades, run } = require("hardhat");
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
// Define a file to store the deployed proxy address
|
||||
const deploymentFile = path.join(__dirname, "deployedAddresses.json");
|
||||
|
||||
async function main() {
|
||||
const impersonatedAddress = "0xfe5FD43b5DD5E9dA362901C5B24EF7aEdC3914B0";
|
||||
|
||||
// Impersonate the account
|
||||
await hre.network.provider.request({
|
||||
method: "hardhat_impersonateAccount",
|
||||
params: [impersonatedAddress],
|
||||
});
|
||||
|
||||
// Get the signer for the impersonated account
|
||||
const deployer = await ethers.getSigner(impersonatedAddress);
|
||||
console.log("Deploying contracts with the account:", deployer.address);
|
||||
|
||||
// Load existing deployment data if it exists
|
||||
let deploymentData = {};
|
||||
if (fs.existsSync(deploymentFile)) {
|
||||
deploymentData = JSON.parse(fs.readFileSync(deploymentFile, "utf8"));
|
||||
}
|
||||
|
||||
const contractName = "PacaFinanceWithBoostAndSchedule";
|
||||
|
||||
let proxyAddress;
|
||||
if (!deploymentData.proxyAddress) {
|
||||
// Deploy the proxy on the first run
|
||||
console.log("Deploying proxy...");
|
||||
|
||||
const Paca = await ethers.getContractFactory(contractName, deployer);
|
||||
|
||||
// Deploy the proxy with the implementation logic
|
||||
const proxy = await upgrades.deployProxy(Paca, [], {
|
||||
initializer: "initialize", // Define the initializer function
|
||||
});
|
||||
|
||||
await proxy.deployed();
|
||||
proxyAddress = proxy.address;
|
||||
console.log("Proxy deployed to:", proxyAddress);
|
||||
|
||||
// Save the proxy address for future upgrades
|
||||
deploymentData.proxyAddress = proxyAddress;
|
||||
fs.writeFileSync(deploymentFile, JSON.stringify(deploymentData, null, 2));
|
||||
} else {
|
||||
proxyAddress = deploymentData.proxyAddress;
|
||||
console.log("Upgrading proxy...");
|
||||
|
||||
const Paca = await ethers.getContractFactory(contractName, deployer);
|
||||
|
||||
// Upgrade the proxy to the new implementation
|
||||
await upgrades.upgradeProxy(proxyAddress, Paca);
|
||||
console.log("Proxy upgraded with new implementation.");
|
||||
}
|
||||
|
||||
// Verify the implementation contract
|
||||
const implementationAddress = await upgrades.erc1967.getImplementationAddress(proxyAddress);
|
||||
console.log("Verifying contracts...");
|
||||
|
||||
// Verify proxy (optional)
|
||||
console.log(`Verifying proxy at ${proxyAddress}...`);
|
||||
try {
|
||||
await run("verify:verify", {
|
||||
address: proxyAddress,
|
||||
});
|
||||
} catch (err) {
|
||||
console.error(`Failed to verify proxy: ${err.message}`);
|
||||
}
|
||||
|
||||
// Verify implementation
|
||||
console.log(`Verifying implementation at ${implementationAddress}...`);
|
||||
try {
|
||||
await run("verify:verify", {
|
||||
address: implementationAddress,
|
||||
});
|
||||
} catch (err) {
|
||||
console.error(`Failed to verify implementation: ${err.message}`);
|
||||
}
|
||||
|
||||
console.log("Verification complete.");
|
||||
}
|
||||
|
||||
main()
|
||||
.then(() => process.exit(0))
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
});
|
||||
130
scripts/deployProxy.js
Normal file
130
scripts/deployProxy.js
Normal file
@@ -0,0 +1,130 @@
|
||||
const { ethers, upgrades, run } = require("hardhat");
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
require('dotenv').config();
|
||||
|
||||
const deploymentFile = path.join(__dirname, "deployedAddresses.json");
|
||||
|
||||
async function main() {
|
||||
const privateKey = process.env.pk;
|
||||
const network = await hre.network.name;
|
||||
|
||||
const wallet = new ethers.Wallet(privateKey, ethers.provider);
|
||||
const deployer = wallet.connect(ethers.provider);
|
||||
console.log(`Using private key for account: ${deployer.address}`);
|
||||
console.log("Deploying contracts with the account:", deployer.address);
|
||||
|
||||
let deploymentData = {};
|
||||
if (fs.existsSync(deploymentFile)) {
|
||||
deploymentData = JSON.parse(fs.readFileSync(deploymentFile, "utf8"));
|
||||
}
|
||||
|
||||
const contractName = network === "mainnet"
|
||||
? "PacaFinanceWithBoostAndScheduleUSDT"
|
||||
: "PacaFinanceWithBoostAndScheduleUSDC";
|
||||
|
||||
let proxyAddress;
|
||||
if (!deploymentData.proxyAddress) {
|
||||
// Initial deployment
|
||||
console.log("Deploying proxy...");
|
||||
const Paca = await ethers.getContractFactory(contractName, deployer);
|
||||
|
||||
const proxy = await upgrades.deployProxy(Paca, [], {
|
||||
initializer: "initialize",
|
||||
});
|
||||
await proxy.waitForDeployment();
|
||||
proxyAddress = proxy.target;
|
||||
|
||||
const implementationAddress = await upgrades.erc1967.getImplementationAddress(proxyAddress);
|
||||
console.log("Proxy deployed to:", proxyAddress);
|
||||
console.log("Implementation deployed to:", implementationAddress);
|
||||
|
||||
deploymentData.proxyAddress = proxyAddress;
|
||||
deploymentData.implementationAddress = implementationAddress;
|
||||
fs.writeFileSync(deploymentFile, JSON.stringify(deploymentData, null, 2));
|
||||
|
||||
await verifyContract(implementationAddress, contractName);
|
||||
} else {
|
||||
// Upgrade
|
||||
proxyAddress = deploymentData.proxyAddress;
|
||||
console.log("Upgrading proxy...");
|
||||
|
||||
const Paca = await ethers.getContractFactory(contractName, deployer);
|
||||
// //commen tout for mainet
|
||||
// await upgrades.forceImport(proxyAddress, Paca);
|
||||
|
||||
// Get current implementation for comparison
|
||||
const oldImplementationAddress = await upgrades.erc1967.getImplementationAddress(proxyAddress);
|
||||
console.log("Current implementation:", oldImplementationAddress);
|
||||
|
||||
// Perform the upgrade
|
||||
console.log("Performing upgrade...");
|
||||
const upgraded = await upgrades.upgradeProxy(proxyAddress, Paca);
|
||||
|
||||
// Wait for deployment to complete
|
||||
await upgraded.waitForDeployment();
|
||||
|
||||
console.log("Waiting 10 seconds before verification...");
|
||||
await new Promise(resolve => setTimeout(resolve, 10000));
|
||||
|
||||
// Get the new implementation address after deployment is complete
|
||||
const newImplementationAddress = await upgrades.erc1967.getImplementationAddress(proxyAddress);
|
||||
|
||||
// Double check we actually have a new address
|
||||
if (newImplementationAddress.toLowerCase() === oldImplementationAddress.toLowerCase()) {
|
||||
console.error("Warning: New implementation address is the same as the old one!");
|
||||
}
|
||||
|
||||
console.log("New implementation deployed to:", newImplementationAddress);
|
||||
|
||||
// Save the new implementation address
|
||||
deploymentData.implementationAddress = newImplementationAddress;
|
||||
fs.writeFileSync(deploymentFile, JSON.stringify(deploymentData, null, 2));
|
||||
|
||||
// Verify the new implementation
|
||||
await verifyContract(newImplementationAddress, contractName);
|
||||
}
|
||||
}
|
||||
|
||||
async function verifyContract(address, contractName) {
|
||||
if (!address) return;
|
||||
|
||||
console.log(`Verifying contract at ${address}...`);
|
||||
|
||||
// Wait a bit before verification
|
||||
console.log("Waiting 10 seconds before verification...");
|
||||
await new Promise(resolve => setTimeout(resolve, 10000));
|
||||
|
||||
try {
|
||||
await run("verify:verify", {
|
||||
address: address,
|
||||
constructorArguments: []
|
||||
});
|
||||
console.log("Contract verified successfully.");
|
||||
} catch (err) {
|
||||
if (err.message.includes("already been verified")) {
|
||||
console.log("Contract is already verified.");
|
||||
} else {
|
||||
console.log("Attempting verification with explicit contract path...");
|
||||
try {
|
||||
await run("verify:verify", {
|
||||
address: address,
|
||||
contract: `contracts/${contractName}.sol:${contractName}`,
|
||||
constructorArguments: []
|
||||
});
|
||||
console.log("Verification successful.");
|
||||
} catch (manualErr) {
|
||||
console.error("Verification failed:", manualErr.message);
|
||||
console.log("\nTo verify manually, run:");
|
||||
console.log(`npx hardhat verify --network ${hre.network.name} ${address}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
main()
|
||||
.then(() => process.exit(0))
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
});
|
||||
30
scripts/deploySOracle.js
Normal file
30
scripts/deploySOracle.js
Normal file
@@ -0,0 +1,30 @@
|
||||
const hre = require("hardhat");
|
||||
|
||||
async function main() {
|
||||
const privateKey = process.env.pk
|
||||
|
||||
const deployer = new ethers.Wallet(privateKey, ethers.provider);
|
||||
|
||||
console.log(
|
||||
"Deploying contracts with the account:",
|
||||
deployer.address
|
||||
);
|
||||
|
||||
// 3) Get the ContractFactory
|
||||
const SPriceOracle = await hre.ethers.getContractFactory("UsdcQuoteV3", deployer);
|
||||
|
||||
// 4) Deploy
|
||||
const contract = await SPriceOracle.deploy();
|
||||
await contract.waitForDeployment();
|
||||
|
||||
console.log("Contract deployed at:", contract.address);
|
||||
|
||||
|
||||
}
|
||||
|
||||
main()
|
||||
.then(() => process.exit(0))
|
||||
.catch(error => {
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
});
|
||||
Reference in New Issue
Block a user