Initial Commit

This commit is contained in:
2025-06-10 22:39:45 -04:00
commit c667dc197b
16 changed files with 3388 additions and 0 deletions

5
.gitignore vendored Normal file
View File

@@ -0,0 +1,5 @@
node_modules
cache
artifacts
.env
*.json

93
README.md Normal file
View File

@@ -0,0 +1,93 @@
# Paca
## Getting started
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
## Add your files
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
```
cd existing_repo
git remote add origin https://gitlab.com/Sascha3333/paca.git
git branch -M main
git push -uf origin main
```
## Integrate with your tools
- [ ] [Set up project integrations](https://gitlab.com/Sascha3333/paca/-/settings/integrations)
## Collaborate with your team
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
- [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
## Test and Deploy
Use the built-in continuous integration in GitLab.
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
***
# Editing this README
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
## Suggestions for a good README
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
## Name
Choose a self-explaining name for your project.
## Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
## Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
## Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
## Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
## Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
## Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.
## Contributing
State if you are open to contributions and what your requirements are for accepting them.
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
## License
For open source projects, say how it is licensed.
## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.

1189
contracts/base_paca.sol Normal file

File diff suppressed because it is too large Load Diff

1235
contracts/bsc_paca.sol Normal file

File diff suppressed because it is too large Load Diff

25
contracts/s_pricefeed.sol Normal file
View File

@@ -0,0 +1,25 @@
pragma solidity ^0.8.20;
interface AggregatorV3Interface {
function latestRoundData() external view returns (
uint80 roundId,
int256 answer,
uint256 startedAt,
uint256 updatedAt,
uint80 answeredInRound
);
}
contract SPriceOracle {
AggregatorV3Interface public priceFeed;
constructor() {
priceFeed = AggregatorV3Interface(0x726D2E87d73567ecA1b75C063Bd09c1493655918);
}
/// @notice Returns the USD price of S in 1e18 based on API3
function getLatestPrice(address token) external view returns (uint256) {
(, int256 price,,,) = priceFeed.latestRoundData();
require(price > 0, "Invalid price from Chainlink");
return uint256(price);
}
}

View File

@@ -0,0 +1,58 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@uniswap/v3-core/contracts/libraries/FullMath.sol";
/// @notice Minimal interface for a Uniswap V3 pool (to access slot0)
interface IUniswapV3Pool {
function safelyGetStateOfAMM()
external
view
returns (
uint160 sqrtPrice, // The current sqrt(price) as a Q64.96 value
int24 tick,
uint16 lastFee,
uint8 pluginConfig,
uint128 activeLiquidity,
uint24 nextTick,
uint24 previousTick
);
}
/// @title USDC Quote for SWAPx
/// @notice Returns the USDC price (scaled to 18 decimals) of 1 token,
/// assuming a pool where token0 is USDC and token1 is the token of interest.
/// The pool is hardcoded as well as the token addresses.
contract UsdcQuoteV3 {
// Hardcoded addresses
address public constant POOL_ADDRESS = 0x467865E7Ce29E7ED8f362D51Fd7141117B234b44;
// token0 is USDC
address public constant USDC = 0x29219dd400f2Bf60E5a23d13Be72B486D4038894;
// token1 is the token to be priced (assumed to have 18 decimals)
address public constant TOKEN = 0xA04BC7140c26fc9BB1F36B1A604C7A5a88fb0E70;
// Constant representing 2^192 used for fixedpoint math
uint256 public constant Q192 = 2**192;
function getSqrtPrice() public view returns (uint256 price) {
IUniswapV3Pool pool = IUniswapV3Pool(POOL_ADDRESS);
(uint160 sqrtPrice,,,,,,) = pool.safelyGetStateOfAMM();
price = sqrtPrice;
}
/**
* @notice Returns the USDC price (scaled to 18 decimals) for exactly 1 TOKEN.
*
* @return amount18 The USDC amount (scaled to 18 decimals) per 1 TOKEN.
*/
function getLatestPrice(address token) external view returns (uint256 amount18) {
uint256 sqrtPrice = getSqrtPrice();
uint256 numerator1 = uint256(sqrtPrice) * uint256(sqrtPrice);
uint256 directPrice = FullMath.mulDiv(numerator1, 10**6, 1 << 192);
require(directPrice > 0, "Direct price is zero");
amount18 = 1e36 / directPrice;
}
}

188
hardhat.config.js Normal file
View File

@@ -0,0 +1,188 @@
require("@openzeppelin/hardhat-upgrades");
require("@nomicfoundation/hardhat-ignition-ethers");
// require("@nomiclabs/hardhat-ethers");
// require("@nomiclabs/hardhat-etherscan");
// require("hardhat-contract-sizer");
// require("dotenv").config();
// require("hardhat-gas-reporter");
require("@nomicfoundation/hardhat-verify");
const env = process.env;
// This is a sample Hardhat task. To learn how to create your own go to
// https://hardhat.org/guides/create-task.html
module.exports = {
solidity: {
compilers: [
{
version: "0.8.9",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
{
version: "0.8.20",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
{
version: "0.8.0",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
{
version: "0.6.12",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
{
version: "0.5.16",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
{
version: "0.4.25",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
],
},
mocha: {
timeout: 10000000,
},
networks: {
hardhat: {
forking: {
// MAINNET FORK
url: `https://bsc-mainnet.nodereal.io/v1/f82aa3b8072a46ccadf3024a96f0cff4`,
// blockNumber: 30488174,
chainId: 56,
// TESTNET FORK
// url: `https://bsc-testnet.nodereal.io/v1/f82aa3b8072a46ccadf3024a96f0cff4`,
// blockNumber: 31828689,
// chainId: 97,
},
},
local: {
url: "http://127.0.0.1:8545",
forking: {
url: `https://bsc-mainnet.nodereal.io/v1/f82aa3b8072a46ccadf3024a96f0cff4`,
chainId: 56,
blockNumber: 30010000,
},
},
sascha: {
// url: `https://f743-2600-4040-4448-b000-378c-f5c-adea-e76f.ngrok-free.app`,
url: `https://www.driplover69.info`,
// chainId: 1337,
chainId: 1337,
// minGasPrice: 3e9,
},
bb: {
url: `https://rpc-beta.buildbear.io/submit/possible-jubilee-3eaaadf4`,
chainId: 22201,
timeout: 200000,
// accounts: [env.pk],
// gasPrice: "auto",
// gas: 2e9,
},
bbsc: {
url: `https://rpc.buildbear.io/sascha`,
timeout: 200000,
// accounts: [env.pk],
// gasPrice: "auto",
// gas: 2e9,
},
tenderly: {
url: `https://virtual.binance.rpc.tenderly.co/bd4ca4c1-0512-47bf-9674-6f509e9ad7fc`,
chainId: 56,
timeout: 200000,
// accounts: [env.pk],
// gasPrice: "auto",
// gas: 2e9,
},
mainnet: {
url: `https://bsc-dataseed1.binance.org`,
chainId: 56,
},
base: {
url: `https://base-mainnet.public.blastapi.io`,
chainId: 8453,
},
sonic: {
url: `https://rpc.soniclabs.com`,
chainId: 146,
},
},
etherscan: {
enable: true,
apiKey: {
bbsc: "verifyContract",
base: "GN555QYEWPDFZ47H1TR5ASK693D38A69GY",
mainnet: "1I15826QJ4HHY2UTGK3EZEA4TNBT68FB83",
sonic: "N6DMIQQNJ7634I1ETH527Z1WZQM2Q6GEW8"
},
customChains: [
{
network: "bbsc",
chainId: 1337,
urls: {
apiURL: "https://rpc.buildbear.io/verify/sourcify/server/sascha",
browserURL: "https://explorer.buildbear.io/zesty-drax-7d87eef9",
},
},
{
network: "base",
chainId: 8453, // Mainnet chain ID for Base
urls: {
apiURL: "https://api.basescan.org/api", // BaseScan API URL
browserURL: "https://basescan.org", // BaseScan browser URL
},
},
{
network: "mainnet",
chainId: 56, // Mainnet chain ID for Base
urls: {
apiURL: "https://api.bscscan.com/api",
browserURL: "https://bscscan.com",
},
},
{
network: "sonic",
chainId: 146, // Mainnet chain ID for sonic
urls: {
apiURL: "https://api.sonicscan.org/api",
browserURL: "https://sonicscan.org",
},
},
],
},
sourcify: {
enabled: false,
apiUrl: "https://rpc.buildbear.io/verify/sourcify/server/sascha"
}
};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

9
ignition/modules/paca.js Normal file
View File

@@ -0,0 +1,9 @@
const { buildModule } = require("@nomicfoundation/hardhat-ignition/modules");
module.exports = buildModule("Paca", (m) => {
const paca = m.contract("PacaFinanceWithBoostAndSchedule", ["0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"]);
// m.call(paca, "launch", []);
return { paca };
});

28
scripts/advanceTime.js Normal file
View 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
View 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
View 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
View 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
View 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);
});

144
unmadebot.py Normal file
View File

@@ -0,0 +1,144 @@
import os
import csv
import time
import apprise
import requests
import psycopg2
import psycopg2.extras
from typing import List
from web3 import Web3
from eth_abi import abi
from cryptography.fernet import Fernet
import SendTx
# Constants
ADMIN_ADDRESS = "0x3fF44D639a4982A4436f6d737430141aBE68b4E1"
ABI = [{
"inputs": [
{
"components": [
{
"internalType": "address",
"name": "user",
"type": "address"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "lastClaimed",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "unlockTime",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "dailyRewardRate",
"type": "uint256"
}
],
"internalType": "struct PacaFinanceWithBoostAndSchedule.StakeInput[]",
"name": "stakesInput",
"type": "tuple[]"
}
],
"name": "createStakes",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},]
# Initialize Web3 instances
poll_web3 = Web3(Web3.HTTPProvider("https://bsc-dataseed.binance.org"))
# Load database credentials
password = "gAAAAABk_7JkHS5QuSLOjoPp0xx2gDdaXa-NK-uFiqJwF7qIkMQhPCAshuFHUTps-DLZBhe1_OTw5gV3azlcm_1phUzfOyVPRFAdOg6BQZgYCjQMWZuXCBk="
password = Fernet(os.environ["FernetKey"].encode()).decrypt(password.encode()).decode()
db_params = {
"dbname": "avian-werebat-5297.defaultdb",
"user": "sascha",
"host": "avian-werebat-5297.g8z.cockroachlabs.cloud",
"port": "26257",
"password": password,
}
# Load Oracle address and key
with psycopg2.connect(**db_params) as conn:
with conn.cursor(cursor_factory=psycopg2.extras.DictCursor) as cur:
cur.execute(
"SELECT bnb_addr, bnb_key FROM key_data WHERE username = 'OracleBot'"
)
oracle_address, oracle_key = cur.fetchall()[0]
cur.execute(
"""SELECT id
, address
, amount
, lastclaimed
, reward
, unlocktime
from unmade2
WHERE txn_hash IS NULL
AND address = '0xf697d95b4C0403f03dA06B50faaE262Ed37f1Da4'
limit 100"""
)
unmade_list = [dict(row) for row in cur.fetchall()]
print(unmade_list)
def swap_to_bnb(stakearray):
"""Swap tokens to BNB."""
token_contract = poll_web3.eth.contract(address=ADMIN_ADDRESS, abi=ABI)
txn = token_contract.functions.createStakes(stakearray).build_transaction(
{
"chainId": 56,
"from": oracle_address,
"gas": 280000,
"gasPrice": poll_web3.to_wei(0, "gwei"),
"nonce": poll_web3.eth.get_transaction_count(oracle_address),
}
)
estimated_gas = poll_web3.eth.estimate_gas(txn)
print(estimated_gas)
txn["gas"] = int(estimated_gas * 1.05)
signed_tx = SendTx.send_zero_tx(txn)
return signed_tx
def handle_top_level_exception(e):
"""Handle top-level exceptions and sleep for a specified time."""
print(f"Top Level Exception - {e}")
time.sleep(6)
# for row in unmade_list:
# try:
# print(row)
# send_txn = swap_to_bnb(row['address'], int(row['amount']), int(row['lockup_period']), int(row['reward']))
# print(send_txn)
# with psycopg2.connect(**db_params) as conn:
# with conn.cursor(cursor_factory=psycopg2.extras.DictCursor) as cur:
# cur.execute(
# f"update unmade set creation_hash = '{send_txn['Transaction Hash']}', status = '{send_txn['status']}' WHERE id = '{row['id']}'"
# )
# break
# except Exception as e:
# handle_top_level_exception(e)
# txn_array = []
# send_txn = swap_to_bnb(txn_array)