Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,11 @@ const config: DeploymentConfig = {
chainId: 146,
accounts,
},
unichain: {
url: process.env.UNICHAIN_RPC || "https://mainnet.unichain.org",
chainId: 130,
accounts,
},
},
etherscan: {
// Your API key for Etherscan
Expand Down Expand Up @@ -241,6 +246,7 @@ const config: DeploymentConfig = {
sei: "sei",
lisk: "abc",
sonic: "abc",
unichain: process.env.UNICHAIN_API_KEY!,
},
customChains: [
{
Expand Down Expand Up @@ -371,6 +377,14 @@ const config: DeploymentConfig = {
browserURL: "https://blockscout.lisk.com/",
},
},
{
network: "unichain",
chainId: 130,
urls: {
apiURL: "https://api.uniscan.xyz/api",
browserURL: "https://uniscan.xyz/",
},
},
],
},
solidity: {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"deploy:registry": "hardhat run scripts/infra/deployRegistry.ts --network",
"deploy:autoHarvester": "hardhat run scripts/infra/deployAutoHarvester.ts --network",
"deploy:contract": "hardhat run scripts/infra/deployContract.js --network",
"deploy:oracles": "hardhat run scripts/infra/deployOracles.js --network",
"deploy:appMulticallv2": "hardhat run scripts/infra/deployAppMulticall.js --network",
"zap": "hardhat run ./scripts/infra/zapViaAggregator.js --network",
"setOracle": "hardhat run ./scripts/manage/setOracle.js --network",
Expand Down
45 changes: 30 additions & 15 deletions scripts/infra/deployChain.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ const hardhat = require("hardhat");
const { upgrades } = require("hardhat");
const { addressBook } = require("blockchain-addressbook");

const { getVerifyCommand } = require("../utils");

/**
* Script used to deploy the basic infrastructure needed to run Beefy.
*/

const ethers = hardhat.ethers;

const chainName = "unichain";
const {
platforms: {
beefyfinance: {
keeper,
voter,
beefyFeeRecipient,
} },
platforms: {
beefyfinance: { keeper, voter, beefyFeeRecipient },
},
} = addressBook.arbitrum;

const TIMELOCK_ADMIN_ROLE = "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5";
Expand All @@ -27,7 +27,7 @@ const config = {
treasuryMultisig: "0x2E52C94502f728A634a7b8eFf5941FB066d3eE76",
totalLimit: "95000000000000000",
callFee: "500000000000000",
strategist: "5000000000000000"
strategist: "5000000000000000",
};

const proposer = config.devMultisig || TRUSTED_EOA;
Expand All @@ -47,28 +47,42 @@ async function main() {
await vaultOwner.deployed();
await vaultOwner.renounceRole(TIMELOCK_ADMIN_ROLE, deployer.address);
console.log(`Vault owner deployed to ${vaultOwner.address}`);

console.log(getVerifyCommand(chainName, "TimelockController", vaultOwner.address, deployParams));

console.log("Deploying strategy owner.");
const stratOwner = await TimelockController.deploy(STRAT_OWNER_DELAY, timelockProposers, timelockExecutors);
await stratOwner.deployed();
await stratOwner.renounceRole(TIMELOCK_ADMIN_ROLE, deployer.address);
console.log(`Strategy owner deployed to ${stratOwner.address}`);
console.log(getVerifyCommand(chainName, "TimelockController", stratOwner.address, deployParams));

console.log("Deploying multicall");
const Multicall = await ethers.getContractFactory("Multicall");
const multicall = await Multicall.deploy();
await multicall.deployed();
console.log(`Multicall deployed to ${multicall.address}`);
console.log(getVerifyCommand(chainName, "Multicall", multicall.address));

const BeefyFeeConfiguratorFactory = await ethers.getContractFactory("BeefyFeeConfigurator");
console.log("Deploying BeefyFeeConfigurator");

const constructorArguments = [keeper, config.totalLimit];
const transparentUpgradableProxy = await upgrades.deployProxy(BeefyFeeConfiguratorFactory, constructorArguments);
await transparentUpgradableProxy.deployed();

await transparentUpgradableProxy.setFeeCategory(0, BigInt(config.totalLimit), BigInt(config.callFee), BigInt(config.strategist), "default", true, true);
console.log(`BeefyFeeConfigurator deployed to ${transparentUpgradableProxy.address}`);
console.log(
getVerifyCommand(chainName, "BeefyFeeConfigurator", transparentUpgradableProxy.address, constructorArguments)
);

await transparentUpgradableProxy.setFeeCategory(
0,
BigInt(config.totalLimit),
BigInt(config.callFee),
BigInt(config.strategist),
"default",
true,
true
);
await transparentUpgradableProxy.transferOwnership(config.devMultisig);

const implementationAddress = await upgrades.erc1967.getImplementationAddress(transparentUpgradableProxy.address);
Expand All @@ -83,19 +97,20 @@ async function main() {
const vault7 = await VaultV7.deploy();
await vault7.deployed();
console.log(`Vault V7 deployed to ${vault7.address}`);
console.log(getVerifyCommand(chainName, "BeefyVaultV7", vault7.address));

const vaultFactory = await VaultFactory.deploy(vault7.address);
await vaultFactory.deployed();
console.log(`Vault Factory deployed to ${vaultFactory.address}`);
console.log(getVerifyCommand(chainName, "BeefyVaultV7Factory", vaultFactory.address));

console.log("Deploying Beefy Swapper");
const BeefySwapper = await ethers.getContractFactory("BeefySwapper");
const beefySwapper = await BeefySwapper.deploy();
await beefySwapper.deployed();

console.log(`Beefy Swapper deployed to ${beefySwapper.address}`);

console.log('Deploying Beefy Oracle');
console.log(getVerifyCommand(chainName, "BeefySwapper", beefySwapper.address));
console.log("Deploying Beefy Oracle");
const BeefyOracle = await ethers.getContractFactory("BeefyOracle");
const beefyOracle = await BeefyOracle.deploy();
await beefyOracle.deployed();
Expand All @@ -106,6 +121,7 @@ async function main() {
beefyOracle.initialize();
beefyOracle.transferOwnership(keeper);
console.log(`Beefy Oracle deployed to ${beefyOracle.address}`);
console.log(getVerifyCommand(chainName, "BeefyOracle", beefyOracle.address));

console.log(`
const devMultisig = '${config.devMultisig}';
Expand Down Expand Up @@ -145,7 +161,7 @@ async function main() {
beefyOracleUniswapV2: '${ethers.constants.AddressZero}',
beefyOracleUniswapV3: '${ethers.constants.AddressZero}',
} as const;
`)
`);
}

main()
Expand All @@ -154,4 +170,3 @@ main()
console.error(error);
process.exit(1);
});

34 changes: 34 additions & 0 deletions scripts/infra/deployOracles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const hardhat = require("hardhat");
const ethers = hardhat.ethers;

const { getVerifyCommand } = require("../utils");

const chainName = "unichain";

const contracts = ["BeefyOracleChainlink", "BeefyOracleUniswapV2", "BeefyOracleUniswapV3"];

async function main() {
await hardhat.run("compile");

const deployedAddresses = {};

// Deploy each oracle contract
for (const contractName of contracts) {
console.log(`\nDeploying ${contractName}...`);

const Contract = await ethers.getContractFactory(contractName);
const contract = await Contract.deploy();
await contract.deployed();

deployedAddresses[contractName] = contract.address;
console.log(`${contractName} deployed to:`, contract.address);
console.log(getVerifyCommand(chainName, contractName, contract.address));
}
}

main()
.then(() => process.exit(0))
.catch(error => {
console.error(error);
process.exit(1);
});
41 changes: 41 additions & 0 deletions scripts/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
const fs = require("fs");

function getContractPath(contractName) {
// Recursively search for contract file
function findContractFile(dir, contractName) {
const files = fs.readdirSync(dir);
for (const file of files) {
const path = `${dir}/${file}`;
const stat = fs.statSync(path);
if (stat.isDirectory()) {
const found = findContractFile(path, contractName);
if (found) return found;
} else if (file.includes(contractName)) {
return path;
}
}
return null;
}

const contractPath = findContractFile("contracts", contractName);
if (!contractPath) {
throw new Error(`Contract ${contractName} not found`);
}
return contractPath;
}

function getVerifyCommand(network, contractName, address, params) {
try {
const contractPath = getContractPath(contractName);
const paramsString = params ? params.map(param => `"${param}"`).join(" ") : "";
return `npx hardhat verify --network ${network} ${contractPath}:${contractName} ${address} ${paramsString}`;
} catch (error) {
console.error(`Error getting verify command for ${contractName}:`, error);
return null;
}
}

module.exports = {
getContractPath,
getVerifyCommand,
};
Loading