Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deploy zkevm #51

Merged
merged 1 commit into from
Dec 21, 2023
Merged
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
38 changes: 35 additions & 3 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ const argv = require('yargs/yargs')()
networkScanKeyBsc: {
type: "string",
},
networkScanKeyZkevm: {
type: "string",
},
privateKey: {
type: "string",
default: "85bb5fa78d5c4ed1fde856e9d0d1fe19973d7a79ce9ed6c0358ee06a4550504e" // random account
Expand All @@ -67,6 +70,13 @@ const argv = require('yargs/yargs')()
type: "number",
default: 0
},
zkevmRpcUrl: {
type: "string",
},
zkevmForkBlock: {
type: "number",
default: 0
},
loggingEnabled: {
type: "boolean",
default: false
Expand Down Expand Up @@ -97,12 +107,14 @@ export default {
argv.hardhatChainId === 1 ? argv.ethRpcUrl :
argv.hardhatChainId === 137 ? argv.maticRpcUrl :
argv.hardhatChainId === 8453 ? argv.baseRpcUrl :
undefined,
argv.hardhatChainId === 1101 ? argv.zkevmRpcUrl :
undefined,
blockNumber:
argv.hardhatChainId === 1 ? argv.ethForkBlock !== 0 ? argv.ethForkBlock : undefined :
argv.hardhatChainId === 137 ? argv.maticForkBlock !== 0 ? argv.maticForkBlock : undefined :
argv.hardhatChainId === 8453 ? argv.baseForkBlock !== 0 ? argv.baseForkBlock : undefined :
undefined
argv.hardhatChainId === 1101 ? argv.zkevmForkBlock !== 0 ? argv.zkevmForkBlock : undefined :
undefined
} : undefined,
accounts: {
mnemonic: "test test test test test test test test test test test junk",
Expand Down Expand Up @@ -139,6 +151,17 @@ export default {
// gas: 50_000_000_000,
accounts: [argv.privateKey],
},
zkevm: {
url: argv.zkevmRpcUrl || '',
chainId: 1101,
accounts: [argv.privateKey],
gasPrice: 1000000000,
verify: {
etherscan: {
apiKey: argv.networkScanKeyZkevm
}
}
},
},
etherscan: {
// https://hardhat.org/plugins/nomiclabs-hardhat-etherscan.html#multiple-api-keys-and-alternative-block-explorers
Expand All @@ -149,6 +172,7 @@ export default {
polygon: argv.networkScanKeyMatic || argv.networkScanKey,
bsc: argv.networkScanKeyBsc,
base: argv.networkScanKeyBase,
zkevm: argv.networkScanKeyZkevm || argv.networkScanKey,
},
customChains: [
{
Expand All @@ -158,7 +182,15 @@ export default {
apiURL: "https://api.basescan.org/api",
browserURL: "https://basescan.org"
}
}
},
{
network: "zkevm",
chainId: 1101,
urls: {
apiURL: "https://api-zkevm.polygonscan.com/api",
browserURL: "https://zkevm.polygonscan.com/"
}
},
]
},
solidity: {
Expand Down
3 changes: 3 additions & 0 deletions scripts/addresses/addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {PolygonAddresses} from "./polygon";
import {SepoliaAddresses} from "./sepolia";
import {ToolsAddresses} from "../models/ToolsAddresses";
import {BaseAddresses} from "./base";
import {ZkEvmAddresses} from "./zkevm";

// tslint:disable-next-line:no-var-requires
const hre = require("hardhat");
Expand All @@ -15,11 +16,13 @@ export class Addresses {
[11155111, SepoliaAddresses.CORE_ADDRESSES],
[137, PolygonAddresses.CORE_ADDRESSES],
[8453, BaseAddresses.CORE_ADDRESSES],
[1101, ZkEvmAddresses.CORE_ADDRESSES],
]);

public static TOOLS = new Map<number, ToolsAddresses>([
[137, PolygonAddresses.TOOLS_ADDRESSES],
[8453, BaseAddresses.TOOLS_ADDRESSES],
[1101, ZkEvmAddresses.TOOLS_ADDRESSES],
]);

public static getCore(): CoreAddresses {
Expand Down
24 changes: 12 additions & 12 deletions scripts/addresses/zkevm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@ import {CoreAddresses} from "../models/CoreAddresses";
import {ToolsAddresses} from "../models/ToolsAddresses";

// noinspection SpellCheckingInspection
export class BaseAddresses {
export class ZkEvmAddresses {

public static CORE_ADDRESSES = new CoreAddresses(
"0x7C1B24c139a3EdA18Ab77C8Fa04A0F816C23e6D4", // tetu
"", // controller
"", // ve
"", // veDist
"", // gauge
"", // bribe
"", // tetuVoter
"", // platformVoter
"", // forwarder
"", // vaultFactory
"", // investFundV2
"0x35B0329118790B8c8FC36262812D92a4923C6795", // controller
"0x0000000000000000000000000000000000000000", // ve
"0x0000000000000000000000000000000000000000", // veDist
"0xd353254872E8797B159594c1E528b8Be9a6cb1F8", // gauge
"0x0000000000000000000000000000000000000000", // bribe
"0x099C314F792e1F91f53765Fc64AaDCcf4dCf1538", // tetuVoter
"0x0000000000000000000000000000000000000000", // platformVoter
"0x255707B70BF90aa112006E1b07B9AeA6De021424", // forwarder
"0xeFBc16b8c973DecA383aAAbAB07153D2EB676556", // vaultFactory
"0x5373C3d09C39D8F256f88E08aa61402FE14A3792", // investFundV2
);

public static TOOLS_ADDRESSES = new ToolsAddresses(
"",// todo
"0xBcda73B7184D5974F77721db79ff8BA190b342ce",
"",// todo
"",// todo
);
Expand Down
23 changes: 13 additions & 10 deletions scripts/deploy/DeployAllProdSimplified.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ async function main() {
const forwarder = await DeployerUtils.deployForwarderSimplified(signer, controller.address, tetu);
const fundAdr = await DeployerUtils.deployProxy(signer, 'InvestFundV2');
const investFund = InvestFundV2__factory.connect(fundAdr, signer);
await RunHelper.runAndWait(() => investFund.init(controller.address));
await RunHelper.runAndWait2(investFund.populateTransaction.init(controller.address));

const vaultImpl = await DeployerUtils.deployContract(signer, 'TetuVaultV2');
const vaultInsuranceImpl = await DeployerUtils.deployContract(signer, 'VaultInsurance');
Expand All @@ -31,16 +31,16 @@ async function main() {
splitterImpl.address,
);

await RunHelper.runAndWait(() => controller.announceAddressChange(2, tetuVoter.address));
await RunHelper.runAndWait(() => controller.announceAddressChange(4, tools.liquidator));
await RunHelper.runAndWait(() => controller.announceAddressChange(5, forwarder.address));
await RunHelper.runAndWait(() => controller.announceAddressChange(6, fundAdr));
await RunHelper.runAndWait2(controller.populateTransaction.announceAddressChange(2, tetuVoter.address));
await RunHelper.runAndWait2(controller.populateTransaction.announceAddressChange(4, tools.liquidator));
await RunHelper.runAndWait2(controller.populateTransaction.announceAddressChange(5, forwarder.address));
await RunHelper.runAndWait2(controller.populateTransaction.announceAddressChange(6, fundAdr));


await RunHelper.runAndWait(() => controller.changeAddress(2)); // TETU_VOTER
await RunHelper.runAndWait(() => controller.changeAddress(4)); // LIQUIDATOR
await RunHelper.runAndWait(() => controller.changeAddress(5)); // FORWARDER
await RunHelper.runAndWait(() => controller.changeAddress(6)); // INVEST_FUND
await RunHelper.runAndWait2(controller.populateTransaction.changeAddress(2)); // TETU_VOTER
await RunHelper.runAndWait2(controller.populateTransaction.changeAddress(4)); // LIQUIDATOR
await RunHelper.runAndWait2(controller.populateTransaction.changeAddress(5)); // FORWARDER
await RunHelper.runAndWait2(controller.populateTransaction.changeAddress(6)); // INVEST_FUND

const result = ` public static CORE_ADDRESSES = new CoreAddresses(
"${tetu}", // tetu
Expand All @@ -60,7 +60,10 @@ async function main() {
}

main()
.then(() => process.exit(0))
.then(() => {
console.log('Script finished successfully');
process.exit(0);
})
.catch(error => {
console.error(error);
process.exit(1);
Expand Down
4 changes: 1 addition & 3 deletions scripts/gov/execute-upgrades.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {ethers} from "hardhat";
import {Addresses} from "../addresses/addresses";
import {ControllerV2__factory} from "../../typechain";
import {RunHelper} from "../utils/RunHelper";
import {txParams} from "../deploy/DeployContract";

// tslint:disable-next-line:no-var-requires
const hre = require("hardhat");
Expand Down Expand Up @@ -31,8 +30,7 @@ async function main() {

console.log('Ready to Update ', proxiesReadyToUpgrade);
if (proxiesReadyToUpgrade.length !== 0) {
const props = await txParams(hre, ethers.provider);
await RunHelper.runAndWait(() => ControllerV2__factory.connect(core.controller, signer).upgradeProxy(proxiesReadyToUpgrade, {...props}));
await RunHelper.runAndWait2(ControllerV2__factory.connect(core.controller, signer).populateTransaction.upgradeProxy(proxiesReadyToUpgrade));
}


Expand Down
56 changes: 28 additions & 28 deletions scripts/utils/DeployerUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class DeployerUtils {
public static async deployMockToken(signer: SignerWithAddress, name = 'MOCK', decimals = 18, premint = true) {
const token = await DeployerUtils.deployContract(signer, 'MockToken', name + '_MOCK_TOKEN', name, decimals) as MockToken;
if (premint) {
await RunHelper.runAndWait(() => token.mint(signer.address, parseUnits('1000000', decimals)));
await RunHelper.runAndWait2(token.populateTransaction.mint(signer.address, parseUnits('1000000', decimals)));
}
return token;
}
Expand All @@ -79,7 +79,7 @@ export class DeployerUtils {
public static async deployProxy(signer: SignerWithAddress, contract: string) {
const logic = await DeployerUtils.deployContract(signer, contract);
const proxy = await DeployerUtils.deployContract(signer, 'ProxyControlled') as ProxyControlled;
await RunHelper.runAndWait(() => proxy.initProxy(logic.address));
await RunHelper.runAndWait2(proxy.populateTransaction.initProxy(logic.address));
return proxy.address;
}

Expand Down Expand Up @@ -112,8 +112,8 @@ export class DeployerUtils {
public static async deployVeTetu(signer: SignerWithAddress, token: string, controller: string, weight = parseUnits('100')) {
const logic = await DeployerUtils.deployContract(signer, 'VeTetu');
const proxy = await DeployerUtils.deployContract(signer, 'ProxyControlled') as ProxyControlled;
await RunHelper.runAndWait(() => proxy.initProxy(logic.address));
await RunHelper.runAndWait(() => VeTetu__factory.connect(proxy.address, signer).init(
await RunHelper.runAndWait2(proxy.populateTransaction.initProxy(logic.address));
await RunHelper.runAndWait2(VeTetu__factory.connect(proxy.address, signer).populateTransaction.init(
token,
weight,
controller
Expand All @@ -131,8 +131,8 @@ export class DeployerUtils {
) {
const logic = await DeployerUtils.deployContract(signer, 'TetuVoter');
const proxy = await DeployerUtils.deployContract(signer, 'ProxyControlled') as ProxyControlled;
await RunHelper.runAndWait(() => proxy.initProxy(logic.address));
await RunHelper.runAndWait(() => TetuVoter__factory.connect(proxy.address, signer).init(
await RunHelper.runAndWait2(proxy.populateTransaction.initProxy(logic.address));
await RunHelper.runAndWait2(TetuVoter__factory.connect(proxy.address, signer).populateTransaction.init(
controller,
ve,
rewardToken,
Expand All @@ -150,8 +150,8 @@ export class DeployerUtils {
) {
const logic = await DeployerUtils.deployContract(signer, 'TetuVoterSimplified');
const proxy = await DeployerUtils.deployContract(signer, 'ProxyControlled') as ProxyControlled;
await RunHelper.runAndWait(() => proxy.initProxy(logic.address));
await RunHelper.runAndWait(() => TetuVoterSimplified__factory.connect(proxy.address, signer).init(
await RunHelper.runAndWait2(proxy.populateTransaction.initProxy(logic.address));
await RunHelper.runAndWait2(TetuVoterSimplified__factory.connect(proxy.address, signer).populateTransaction.init(
controller,
rewardToken,
gauge,
Expand All @@ -167,8 +167,8 @@ export class DeployerUtils {
) {
const logic = await DeployerUtils.deployContract(signer, 'MultiGauge');
const proxy = await DeployerUtils.deployContract(signer, 'ProxyControlled') as ProxyControlled;
await RunHelper.runAndWait(() => proxy.initProxy(logic.address));
await RunHelper.runAndWait(() => MultiGauge__factory.connect(proxy.address, signer).init(
await RunHelper.runAndWait2(proxy.populateTransaction.initProxy(logic.address));
await RunHelper.runAndWait2(MultiGauge__factory.connect(proxy.address, signer).populateTransaction.init(
controller,
ve,
defaultRewardToken,
Expand All @@ -183,8 +183,8 @@ export class DeployerUtils {
) {
const logic = await DeployerUtils.deployContract(signer, 'MultiGaugeNoBoost');
const proxy = await DeployerUtils.deployContract(signer, 'ProxyControlled') as ProxyControlled;
await RunHelper.runAndWait(() => proxy.initProxy(logic.address));
await RunHelper.runAndWait(() => MultiGaugeNoBoost__factory.connect(proxy.address, signer).init(
await RunHelper.runAndWait2(proxy.populateTransaction.initProxy(logic.address));
await RunHelper.runAndWait2(MultiGaugeNoBoost__factory.connect(proxy.address, signer).populateTransaction.init(
controller,
defaultRewardToken,
));
Expand All @@ -199,8 +199,8 @@ export class DeployerUtils {
) {
const logic = await DeployerUtils.deployContract(signer, 'MultiBribe');
const proxy = await DeployerUtils.deployContract(signer, 'ProxyControlled') as ProxyControlled;
await RunHelper.runAndWait(() => proxy.initProxy(logic.address));
await RunHelper.runAndWait(() => MultiBribe__factory.connect(proxy.address, signer).init(
await RunHelper.runAndWait2(proxy.populateTransaction.initProxy(logic.address));
await RunHelper.runAndWait2(MultiBribe__factory.connect(proxy.address, signer).populateTransaction.init(
controller,
ve,
defaultReward
Expand All @@ -220,8 +220,8 @@ export class DeployerUtils {
) {
const logic = await DeployerUtils.deployContract(signer, 'VeDistributor');
const proxy = await DeployerUtils.deployContract(signer, 'ProxyControlled') as ProxyControlled;
await RunHelper.runAndWait(() => proxy.initProxy(logic.address));
await RunHelper.runAndWait(() => VeDistributor__factory.connect(proxy.address, signer).init(
await RunHelper.runAndWait2(proxy.populateTransaction.initProxy(logic.address));
await RunHelper.runAndWait2(VeDistributor__factory.connect(proxy.address, signer).populateTransaction.init(
controller,
ve,
rewardToken
Expand All @@ -237,8 +237,8 @@ export class DeployerUtils {
) {
const logic = await DeployerUtils.deployContract(signer, 'VeDistributorV2');
const proxy = await DeployerUtils.deployContract(signer, 'ProxyControlled') as ProxyControlled;
await RunHelper.runAndWait(() => proxy.initProxy(logic.address));
await RunHelper.runAndWait(() => VeDistributorV2__factory.connect(proxy.address, signer).init(
await RunHelper.runAndWait2(proxy.populateTransaction.initProxy(logic.address));
await RunHelper.runAndWait2(VeDistributorV2__factory.connect(proxy.address, signer).populateTransaction.init(
controller,
ve,
rewardToken
Expand Down Expand Up @@ -299,9 +299,9 @@ export class DeployerUtils {
) {
const logic = await DeployerUtils.deployContract(signer, 'ForwarderV3') as ForwarderV3;
const proxy = await DeployerUtils.deployContract(signer, 'ProxyControlled') as ProxyControlled;
await RunHelper.runAndWait(() => proxy.initProxy(logic.address));
await RunHelper.runAndWait2(proxy.populateTransaction.initProxy(logic.address));
const forwarder = ForwarderV3__factory.connect(proxy.address, signer);
await RunHelper.runAndWait(() => forwarder.init(
await RunHelper.runAndWait2(forwarder.populateTransaction.init(
controller,
tetu,
bribe
Expand All @@ -316,9 +316,9 @@ export class DeployerUtils {
) {
const logic = await DeployerUtils.deployContract(signer, 'ForwarderV4');
const proxy = await DeployerUtils.deployContract(signer, 'ProxyControlled') as ProxyControlled;
await RunHelper.runAndWait(() => proxy.initProxy(logic.address));
await RunHelper.runAndWait2(proxy.populateTransaction.initProxy(logic.address));
const forwarder = ForwarderV4__factory.connect(proxy.address, signer);
await RunHelper.runAndWait(() => forwarder.init(
await RunHelper.runAndWait2(forwarder.populateTransaction.init(
controller,
tetu,
));
Expand All @@ -332,9 +332,9 @@ export class DeployerUtils {
) {
const logic = await DeployerUtils.deployContract(signer, 'PlatformVoter') as PlatformVoter;
const proxy = await DeployerUtils.deployContract(signer, 'ProxyControlled') as ProxyControlled;
await RunHelper.runAndWait(() => proxy.initProxy(logic.address));
await RunHelper.runAndWait2(proxy.populateTransaction.initProxy(logic.address));
const forwarder = PlatformVoter__factory.connect(proxy.address, signer);
await RunHelper.runAndWait(() => forwarder.init(
await RunHelper.runAndWait2(forwarder.populateTransaction.init(
controller,
ve
));
Expand All @@ -344,18 +344,18 @@ export class DeployerUtils {
public static async deployController(signer: SignerWithAddress) {
const logic = await DeployerUtils.deployContract(signer, 'ControllerV2') as ControllerV2;
const proxy = await DeployerUtils.deployContract(signer, 'ProxyControlled') as ProxyControlled;
await RunHelper.runAndWait(() => proxy.initProxy(logic.address));
await RunHelper.runAndWait2(proxy.populateTransaction.initProxy(logic.address));
const controller = ControllerV2__factory.connect(proxy.address, signer);
await RunHelper.runAndWait(() => controller.init(signer.address));
await RunHelper.runAndWait2(controller.populateTransaction.init(signer.address));
return controller;
}

public static async deployTetuEmitter(signer: SignerWithAddress, controller: string, token: string, bribe: string) {
const logic = await DeployerUtils.deployContract(signer, 'TetuEmitter') as ControllerV2;
const proxy = await DeployerUtils.deployContract(signer, 'ProxyControlled') as ProxyControlled;
await RunHelper.runAndWait(() => proxy.initProxy(logic.address));
await RunHelper.runAndWait2(proxy.populateTransaction.initProxy(logic.address));
const contract = TetuEmitter__factory.connect(proxy.address, signer);
await RunHelper.runAndWait(() => contract.init(controller, token, bribe));
await RunHelper.runAndWait2(contract.populateTransaction.init(controller, token, bribe));
return contract;
}

Expand Down
Loading
Loading