Skip to content

Commit

Permalink
Merge branch 'master' into feat/refactor-parent-pool-to-3-contracts
Browse files Browse the repository at this point in the history
# Conflicts:
#	packages/hardhat/deploy/ParentPool.ts
#	packages/hardhat/tasks/concero/deployInfra/deployInfra.ts
#	packages/hardhat/tasks/concero/deployPool/deployParentPool.ts
#	packages/hardhat/tasks/concero/deployPool/setParentPoolVariables.ts
  • Loading branch information
lufaque committed Sep 20, 2024
2 parents 0b3b18d + a099211 commit f15c172
Show file tree
Hide file tree
Showing 78 changed files with 666 additions and 676 deletions.
11 changes: 1 addition & 10 deletions packages/hardhat/constants/CLFSecrets.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
import { getEnvVar } from "../utils/getEnvVar";

type envString = string | undefined;
export type CLFSecrets = {
MESSENGER_0_PRIVATE_KEY: envString;
MESSENGER_1_PRIVATE_KEY: envString;
MESSENGER_2_PRIVATE_KEY: envString;
POOL_MESSENGER_0_PRIVATE_KEY: envString;
INFURA_API_KEY: envString;
ALCHEMY_API_KEY: envString;
};
import { CLFSecrets } from "../types/CLFSecrets";

const secrets: CLFSecrets = {
MESSENGER_0_PRIVATE_KEY: getEnvVar("MESSENGER_0_PRIVATE_KEY"),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Purpose: To have a single source of truth for networks across the project
import { type CNetwork, CNetworkNames } from "../types/CNetwork";
import { type CNetwork, CNetworkNames, NetworkType } from "../types/CNetwork";
import { HardhatNetworkUserConfig } from "hardhat/src/types/config";
import {
arbitrum,
Expand All @@ -14,15 +14,12 @@ import {
sepolia,
} from "viem/chains";
import { urls } from "./rpcUrls";
import { getEnvVar } from "../utils/getEnvVar";

const DEFAULT_BLOCK_CONFIRMATIONS = 2;
const deployerPK = getEnvVar("DEPLOYER_PRIVATE_KEY");
const proxyDeployerPK = getEnvVar("PROXY_DEPLOYER_PRIVATE_KEY");
const deployerPK = process.env.DEPLOYER_PRIVATE_KEY;
const proxyDeployerPK = process.env.PROXY_DEPLOYER_PRIVATE_KEY;
const saveDeployments = false;

export type NetworkType = "mainnet" | "testnet";

export const networkTypes: Record<NetworkType, string> = {
mainnet: "mainnet",
testnet: "testnet",
Expand Down Expand Up @@ -51,7 +48,7 @@ export const functionsGatewayUrls = {
testnet: ["https://01.functions-gateway.testnet.chain.link/", "https://02.functions-gateway.testnet.chain.link/"],
};

const CNetworks: Record<CNetworkNames, CNetwork> = {
export const cNetworks: Record<CNetworkNames, CNetwork> = {
localhost: {
accounts: [deployerPK, proxyDeployerPK],
// mock CLF data
Expand Down Expand Up @@ -378,4 +375,4 @@ const CNetworks: Record<CNetworkNames, CNetwork> = {
name: "avalanche",
},
};
export default CNetworks;
export default cNetworks;
42 changes: 10 additions & 32 deletions packages/hardhat/constants/deploymentVariables.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getEnvVar } from "../utils/getEnvVar";
import { getEnvVar } from "../utils";
import type { WaitForTransactionReceiptParameters } from "viem/actions/public/waitForTransactionReceipt";
import { WriteContractParameters } from "viem";
import { EnvPrefixes } from "../types/deploymentVariables";

export const messengers: string[] = [
getEnvVar("MESSENGER_0_ADDRESS"),
Expand All @@ -12,7 +13,6 @@ export const poolMessengers: string[] = [
getEnvVar("POOL_MESSENGER_0_ADDRESS"),
getEnvVar("POOL_MESSENGER_0_ADDRESS"),
];
// The address is the same on 4 chains: ARB,POL,BASE,AVAX. Can be deployed to others later using Lifi's Create3 Factory.

export const viemReceiptConfig: WaitForTransactionReceiptParameters = {
timeout: 0,
Expand All @@ -21,41 +21,13 @@ export const viemReceiptConfig: WaitForTransactionReceiptParameters = {
export const writeContractConfig: WriteContractParameters = {
gas: 3000000n, // 3M
};
export enum ProxyType {
export enum ProxyEnum {
infraProxy = "infraProxy",
parentPoolProxy = "parentPoolProxy",
childPoolProxy = "childPoolProxy",
}

export type IProxyType = keyof typeof ProxyType;

type ProxyDeploymentPrefixes = {
[key in ProxyType]: string;
};

export type DeploymentPrefixes = ProxyDeploymentPrefixes & {
infraProxyAdmin: string;
bridge: string;
dexSwap: string;
orchestrator: string;
parentPoolProxyAdmin: string;
parentPool: string;
childPoolProxyAdmin: string;
childPool: string;
automation: string;
lpToken: string;
create3Factory: string;
pause: string;
uniswapRouter: string;
poolMessenger0: string;
poolMessenger1: string;
poolMessenger2: string;
infraMessenger0: string;
infraMessenger1: string;
infraMessenger2: string;
};

export const deploymentPrefixes: DeploymentPrefixes = {
export const envPrefixes: EnvPrefixes = {
infraProxy: "CONCERO_INFRA_PROXY",
infraProxyAdmin: "CONCERO_INFRA_PROXY_ADMIN",
bridge: "CONCERO_BRIDGE",
Expand All @@ -72,4 +44,10 @@ export const deploymentPrefixes: DeploymentPrefixes = {
create3Factory: "CREATE3_FACTORY",
pause: "CONCERO_PAUSE",
uniswapRouter: "UNISWAP_ROUTER",
poolMessenger0: "POOL_MESSENGER_0_ADDRESS",
poolMessenger1: "POOL_MESSENGER_1_ADDRESS",
poolMessenger2: "POOL_MESSENGER_2_ADDRESS",
infraMessenger0: "MESSENGER_0_ADDRESS",
infraMessenger1: "MESSENGER_1_ADDRESS",
infraMessenger2: "MESSENGER_2_ADDRESS",
};
41 changes: 41 additions & 0 deletions packages/hardhat/constants/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import secrets from "./CLFSecrets";
import CLFnetworks from "./CLFnetworks";
import CLFSimulationConfig from "./CLFSimulationConfig";
import { cNetworks, functionsGatewayUrls, networkEnvKeys, networkTypes } from "./cNetworks";
import {
envPrefixes,
messengers,
poolMessengers,
ProxyEnum,
viemReceiptConfig,
writeContractConfig,
} from "./deploymentVariables";
import { rpc, urls } from "./rpcUrls";
import { deployerTargetBalances, messengerTargetBalances } from "./targetBalances";
import { conceroChains, liveChains, mainnetChains, testnetChains } from "./liveChains";

export {
secrets,
CLFnetworks,
CLFSimulationConfig,
cNetworks,
networkTypes,
networkEnvKeys,
functionsGatewayUrls,
messengers,
poolMessengers,
viemReceiptConfig,
writeContractConfig,
ProxyEnum,
envPrefixes,
urls,
rpc,
messengerTargetBalances,
deployerTargetBalances,
liveChains,
mainnetChains,
testnetChains,
conceroChains,
};

export default CLFnetworks;
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { CNetwork } from "../../types/CNetwork";
import chains from "../../constants/CNetworks";
import { CNetwork } from "../types/CNetwork";
import chains from "./cNetworks";
import { ConceroChains } from "../types/chains";

// export const liveChains: CNetwork[] = [
// chains.baseSepolia,
Expand All @@ -11,19 +12,6 @@ import chains from "../../constants/CNetworks";

export const liveChains: CNetwork[] = [chains.polygon, chains.base, chains.arbitrum, chains.avalanche];

export interface ConceroChains {
testnet: {
parentPool: CNetwork[];
childPool: CNetwork[];
infra: CNetwork[];
};
mainnet: {
parentPool: CNetwork[];
childPool: CNetwork[];
infra: CNetwork[];
};
}

export const conceroChains: ConceroChains = {
testnet: {
parentPool: [chains.baseSepolia],
Expand All @@ -37,14 +25,10 @@ export const conceroChains: ConceroChains = {
},
};

export const testnetChains: CNetwork[] = Array.from(new Set([
...conceroChains.testnet.parentPool,
...conceroChains.testnet.childPool,
...conceroChains.testnet.infra,
]));
export const testnetChains: CNetwork[] = Array.from(
new Set([...conceroChains.testnet.parentPool, ...conceroChains.testnet.childPool, ...conceroChains.testnet.infra]),
);

export const mainnetChains: CNetwork[] = Array.from(new Set([
...conceroChains.mainnet.parentPool,
...conceroChains.mainnet.childPool,
...conceroChains.mainnet.infra,
]));
export const mainnetChains: CNetwork[] = Array.from(
new Set([...conceroChains.mainnet.parentPool, ...conceroChains.mainnet.childPool, ...conceroChains.mainnet.infra]),
);
2 changes: 1 addition & 1 deletion packages/hardhat/constants/rpcUrls.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { INFURA_API_KEY, ALCHEMY_API_KEY, BLAST_API_KEY, CHAINSTACK_API_KEY, TENDERLY_API_KEY } = process.env;

const rpc: Record<string, string> = {
export const rpc: Record<string, string> = {
arbitrum: `https://arbitrum-mainnet.infura.io/v3/${INFURA_API_KEY}`,
arbitrumSepolia: `https://arbitrum-sepolia.infura.io/v3/${INFURA_API_KEY}`,
base: `https://base-sepolia.infura.io/v3/${INFURA_API_KEY}`,
Expand Down
6 changes: 3 additions & 3 deletions packages/hardhat/deploy/ChildPool.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Deployment } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import chains, { networkEnvKeys } from "../constants/CNetworks";
import chains, { networkEnvKeys } from "../constants/cNetworks";
import updateEnvVariable from "../utils/updateEnvVariable";
import log from "../utils/log";
import { getEnvVar } from "../utils/getEnvVar";
import { poolMessengers } from "../constants/deploymentVariables";
import { getEnvVar } from "../utils";
import { poolMessengers } from "../constants";

interface ConstructorArgs {
conceroProxyAddress?: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/hardhat/deploy/ConceroAutomation.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// import { Deployment } from "hardhat-deploy/types";
// import { HardhatRuntimeEnvironment } from "hardhat/types";
// import chains, { networkEnvKeys } from "../constants/CNetworks";
// import chains, { networkEnvKeys } from "../constants/cNetworks";
// import updateEnvVariable from "../utils/updateEnvVariable";
// import log from "../utils/log";
// import getHashSum from "../utils/getHashSum";
Expand Down
6 changes: 3 additions & 3 deletions packages/hardhat/deploy/ConceroBridge.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Deployment } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import chains, { networkEnvKeys } from "../constants/CNetworks";
import chains, { networkEnvKeys } from "../constants/cNetworks";
import updateEnvVariable from "../utils/updateEnvVariable";
import log from "../utils/log";
import path from "path";
import fs from "fs";
import { getEnvVar } from "../utils/getEnvVar";
import { messengers } from "../constants/deploymentVariables";
import { getEnvVar } from "../utils";
import { messengers } from "../constants";

interface ConstructorArgs {
slotId?: number;
Expand Down
8 changes: 4 additions & 4 deletions packages/hardhat/deploy/ConceroDexSwap.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { Deployment } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import CNetworks, { networkEnvKeys } from "../constants/CNetworks";
import cNetworks, { networkEnvKeys } from "../constants/cNetworks";
import updateEnvVariable from "../utils/updateEnvVariable";
import log from "../utils/log";
import { getEnvVar } from "../utils/getEnvVar";
import { messengers } from "../constants/deploymentVariables";
import { getEnvVar } from "../utils";
import { messengers } from "../constants";

const deployConceroDexSwap: (hre: HardhatRuntimeEnvironment) => Promise<void> = async function (
hre: HardhatRuntimeEnvironment,
) {
const { deployer } = await hre.getNamedAccounts();
const { deploy } = hre.deployments;
const { name, live } = hre.network;
const networkType = CNetworks[name].type;
const networkType = cNetworks[name].type;

const conceroProxyAddress = getEnvVar(`CONCERO_INFRA_PROXY_${networkEnvKeys[name]}`);

Expand Down
8 changes: 4 additions & 4 deletions packages/hardhat/deploy/ConceroFakePool.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Deployment } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import chains from "../constants/CNetworks";
import CNetworks, { networkEnvKeys } from "../constants/CNetworks";
import chains from "../constants/cNetworks";
import cNetworks, { networkEnvKeys } from "../constants/cNetworks";
import updateEnvVariable from "../utils/updateEnvVariable";
import log from "../utils/log";
import { getEnvVar } from "../utils/getEnvVar";
import { getEnvVar } from "../utils";

interface ConstructorArgs {
linkToken?: string;
Expand All @@ -16,7 +16,7 @@ const deployConceroPool: (hre: HardhatRuntimeEnvironment, constructorArgs?: Cons
const { deployer } = await hre.getNamedAccounts();
const { deploy } = hre.deployments;
const { name, live } = hre.network;
const networkType = CNetworks[name].type;
const networkType = cNetworks[name].type;

const { linkToken, ccipRouter } = chains[name];

Expand Down
6 changes: 3 additions & 3 deletions packages/hardhat/deploy/ConceroOrchestrator.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Deployment } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import chains, { networkEnvKeys } from "../constants/CNetworks";
import chains, { networkEnvKeys } from "../constants/cNetworks";
import updateEnvVariable from "../utils/updateEnvVariable";
import log from "../utils/log";
import { getEnvVar } from "../utils/getEnvVar";
import { messengers } from "../constants/deploymentVariables";
import { getEnvVar } from "../utils";
import { messengers } from "../constants";

const deployConceroOrchestrator: (hre: HardhatRuntimeEnvironment) => Promise<void> = async function (
hre: HardhatRuntimeEnvironment,
Expand Down
10 changes: 5 additions & 5 deletions packages/hardhat/deploy/ConceroProxyAdmin.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Deployment } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import CNetworks from "../constants/CNetworks";
import { updateEnvAddress } from "../utils/updateEnvVariable";
import cNetworks from "../constants/cNetworks";
import { getEnvVar, updateEnvAddress } from "../utils";
import log from "../utils/log";
import { getEnvVar } from "../utils/getEnvVar";
import { type IProxyType } from "../constants/deploymentVariables";

import { IProxyType } from "../types/deploymentVariables";

const deployProxyAdmin: (hre: HardhatRuntimeEnvironment, proxyType: IProxyType) => Promise<void> = async function (
hre: HardhatRuntimeEnvironment,
Expand All @@ -13,7 +13,7 @@ const deployProxyAdmin: (hre: HardhatRuntimeEnvironment, proxyType: IProxyType)
const { proxyDeployer } = await hre.getNamedAccounts();
const { deploy } = hre.deployments;
const { name, live } = hre.network;
const networkType = CNetworks[name].type;
const networkType = cNetworks[name].type;

const initialOwner = getEnvVar(`PROXY_DEPLOYER_ADDRESS`);

Expand Down
6 changes: 3 additions & 3 deletions packages/hardhat/deploy/LPToken.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Deployment } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import CNetworks, { networkEnvKeys } from "../constants/CNetworks";
import cNetworks, { networkEnvKeys } from "../constants/cNetworks";
import updateEnvVariable from "../utils/updateEnvVariable";
import log from "../utils/log";
import { getEnvVar } from "../utils/getEnvVar";
import { getEnvVar } from "../utils";

interface ConstructorArgs {
parentProxyAddress?: string;
Expand All @@ -15,7 +15,7 @@ const deployLPToken: (hre: HardhatRuntimeEnvironment, constructorArgs?: Construc
const { proxyDeployer } = await hre.getNamedAccounts();
const { deploy } = hre.deployments;
const { name, live } = hre.network;
const networkType = CNetworks[name].type;
const networkType = cNetworks[name].type;

const defaultArgs = {
parentProxyAddress: getEnvVar(`PARENT_POOL_PROXY_${networkEnvKeys[name]}`),
Expand Down
6 changes: 3 additions & 3 deletions packages/hardhat/deploy/ParentPool.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Deployment } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import chains, { networkEnvKeys } from "../constants/CNetworks";
import chains, { networkEnvKeys } from "../constants/cNetworks";
import updateEnvVariable from "../utils/updateEnvVariable";
import log from "../utils/log";
import { getEnvVar } from "../utils/getEnvVar";
import { poolMessengers } from "../constants/deploymentVariables";
import { zeroAddress } from "viem";
import { getEnvVar } from "../utils";
import { poolMessengers } from "../constants";

interface ConstructorArgs {
automationForwarder?: string;
Expand Down
Loading

0 comments on commit f15c172

Please sign in to comment.