Skip to content

Commit

Permalink
Merge branch 'feat/ven-2878' into feat/ven-2879
Browse files Browse the repository at this point in the history
  • Loading branch information
chechu committed Dec 3, 2024
2 parents 8d40d6a + 6ae925a commit 722b2be
Show file tree
Hide file tree
Showing 235 changed files with 82,098 additions and 635 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ gnosisTXBuilder.json
**/.DS_Store

.cache
.vscode/settings.json
53 changes: 38 additions & 15 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import "@nomiclabs/hardhat-ethers";
import * as dotenv from "dotenv";
import { ethers } from "ethers";
import { HardhatUserConfig, task } from "hardhat/config";
import { ChainId } from "src/chains";

import "./type-extensions";

Expand All @@ -26,11 +27,11 @@ const BLOCK_GAS_LIMIT_PER_NETWORK = {
ethereum: 30000000,
opbnbtestnet: 100000000,
opbnbmainnet: 100000000,
arbitrumsepolia: 30000000,
arbitrumone: 30000000,
opsepolia: 30000000,
opmainnet: 30000000,
basesepolia: 30000000,
arbitrumsepolia: 32000000,
arbitrumone: 32000000,
opsepolia: 60000000,
opmainnet: 60000000,
basesepolia: 60000000,
};

task("propose", "Propose proposal")
Expand Down Expand Up @@ -96,16 +97,37 @@ task("test", "Update fork config")
await runSuper(taskArguments);
});

// Pretend that Cancun hardfork was activated at block 0
const assumeCancun = {
hardforkHistory: {
cancun: 0,
},
};

const config: HardhatUserConfig = {
defaultNetwork: "hardhat",
networks: {
hardhat: {
allowUnlimitedContractSize: true,
loggingEnabled: false,
// Forking networks with unknown hardfork activation history causes errors in
// new versions of Hardhat. Following https://github.com/NomicFoundation/hardhat/pull/5394,
// we assume Cancun hardfork was active from the beginning for all unknown chains
chains: {
[ChainId.bscmainnet]: assumeCancun,
[ChainId.bsctestnet]: assumeCancun,
[ChainId.opbnbtestnet]: assumeCancun,
[ChainId.opbnbmainnet]: assumeCancun,
[ChainId.arbitrumsepolia]: assumeCancun,
[ChainId.arbitrumone]: assumeCancun,
[ChainId.opsepolia]: assumeCancun,
[ChainId.opmainnet]: assumeCancun,
[ChainId.basesepolia]: assumeCancun,
},
},
bsctestnet: {
url: process.env.ARCHIVE_NODE_bsctestnet || "https://data-seed-prebsc-1-s1.binance.org:8545",
chainId: 97,
chainId: ChainId.bsctestnet,
accounts: DEPLOYER_PRIVATE_KEY ? [`0x${DEPLOYER_PRIVATE_KEY}`] : [],
gasPrice: ethers.utils.parseUnits("10", "gwei").toNumber(),
gasMultiplier: 10,
Expand All @@ -114,58 +136,59 @@ const config: HardhatUserConfig = {
},
bscmainnet: {
url: process.env.ARCHIVE_NODE_bscmainnet || "https://bsc-dataseed.binance.org/",
chainId: ChainId.bscmainnet,
accounts: DEPLOYER_PRIVATE_KEY ? [`0x${DEPLOYER_PRIVATE_KEY}`] : [],
blockGasLimit: BLOCK_GAS_LIMIT_PER_NETWORK.bscmainnet,
},
sepolia: {
url: process.env.ARCHIVE_NODE_sepolia || "https://ethereum-sepolia.blockpi.network/v1/rpc/public",
chainId: 11155111,
chainId: ChainId.sepolia,
accounts: DEPLOYER_PRIVATE_KEY ? [`0x${DEPLOYER_PRIVATE_KEY}`] : [],
blockGasLimit: BLOCK_GAS_LIMIT_PER_NETWORK.sepolia,
},
ethereum: {
url: process.env.ARCHIVE_NODE_ethereum || "https://ethereum.blockpi.network/v1/rpc/public",
chainId: 1,
chainId: ChainId.ethereum,
accounts: DEPLOYER_PRIVATE_KEY ? [`0x${DEPLOYER_PRIVATE_KEY}`] : [],
blockGasLimit: BLOCK_GAS_LIMIT_PER_NETWORK.ethereum,
},
opbnbtestnet: {
url: process.env.ARCHIVE_NODE_opbnbtestnet || "https://opbnb-testnet-rpc.bnbchain.org",
chainId: 5611,
chainId: ChainId.opbnbtestnet,
accounts: DEPLOYER_PRIVATE_KEY ? [`0x${DEPLOYER_PRIVATE_KEY}`] : [],
blockGasLimit: BLOCK_GAS_LIMIT_PER_NETWORK.opbnbtestnet,
},
opbnbmainnet: {
url: process.env.ARCHIVE_NODE_opbnbmainnet || "https://opbnb-mainnet-rpc.bnbchain.org",
chainId: 204,
chainId: ChainId.opbnbmainnet,
accounts: DEPLOYER_PRIVATE_KEY ? [`0x${DEPLOYER_PRIVATE_KEY}`] : [],
blockGasLimit: BLOCK_GAS_LIMIT_PER_NETWORK.opbnbmainnet,
},
arbitrumsepolia: {
url: process.env.ARCHIVE_NODE_arbitrumsepolia || "https://sepolia-rollup.arbitrum.io/rpc",
chainId: 421614,
chainId: ChainId.arbitrumsepolia,
accounts: DEPLOYER_PRIVATE_KEY ? [`0x${DEPLOYER_PRIVATE_KEY}`] : [],
},
arbitrumone: {
url: process.env.ARCHIVE_NODE_arbitrumone || "https://arb1.arbitrum.io/rpc",
chainId: 42161,
chainId: ChainId.arbitrumone,
accounts: DEPLOYER_PRIVATE_KEY ? [`0x${DEPLOYER_PRIVATE_KEY}`] : [],
},
opsepolia: {
url: process.env.ARCHIVE_NODE_opsepolia || "https://sepolia.optimism.io",
chainId: 11155420,
chainId: ChainId.opsepolia,
accounts: DEPLOYER_PRIVATE_KEY ? [`0x${DEPLOYER_PRIVATE_KEY}`] : [],
blockGasLimit: BLOCK_GAS_LIMIT_PER_NETWORK.opsepolia,
},
opmainnet: {
url: process.env.ARCHIVE_NODE_opmainnet || "https://mainnet.optimism.io",
chainId: 10,
chainId: ChainId.opmainnet,
accounts: DEPLOYER_PRIVATE_KEY ? [`0x${DEPLOYER_PRIVATE_KEY}`] : [],
blockGasLimit: BLOCK_GAS_LIMIT_PER_NETWORK.opmainnet,
},
basesepolia: {
url: process.env.ARCHIVE_NODE_basesepolia || "https://sepolia.base.org",
chainId: 84532,
chainId: ChainId.basesepolia,
accounts: DEPLOYER_PRIVATE_KEY ? [`0x${DEPLOYER_PRIVATE_KEY}`] : [],
blockGasLimit: BLOCK_GAS_LIMIT_PER_NETWORK.basesepolia,
},
Expand Down
21 changes: 17 additions & 4 deletions hardhat.config.zksync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import "@nomicfoundation/hardhat-chai-matchers";
import "@nomiclabs/hardhat-ethers";
import * as dotenv from "dotenv";
import { HardhatUserConfig, task } from "hardhat/config";
import { ChainId } from "src/chains";

import "./type-extensions";

Expand Down Expand Up @@ -50,7 +51,7 @@ task("test", "Update fork config")
.setAction(async function (taskArguments, hre, runSuper) {
const { fork } = taskArguments;

if (hre.network.name === "zkSyncTestNode") {
if (hre.network.name === "zksynctestnode") {
if (!process.env["ZKSYNC_ERA_LOCAL_TEST_NODE"]) {
throw new Error("ZKSYNC_ERA_LOCAL_TEST_NODE env variable is not set");
}
Expand All @@ -71,7 +72,7 @@ task("test", "Update fork config")
allowUnlimitedContractSize: false,
loggingEnabled: false,
forking:
hre.network.name === "zkSyncTestNode"
hre.network.name === "zksynctestnode"
? {
enabled: false,
url: process.env["ZKSYNC_ERA_LOCAL_TEST_NODE"] as string,
Expand All @@ -94,6 +95,13 @@ task("test", "Update fork config")
await runSuper(taskArguments);
});

// Pretend that Cancun hardfork was activated at block 0
const assumeCancun = {
hardforkHistory: {
cancun: 0,
},
};

const config: HardhatUserConfig = {
defaultNetwork: "hardhat",
zksolc: {
Expand Down Expand Up @@ -132,6 +140,11 @@ const config: HardhatUserConfig = {
allowUnlimitedContractSize: true,
loggingEnabled: false,
zksync: true,
chains: {
[ChainId.zksyncmainnet]: assumeCancun,
[ChainId.zksyncsepolia]: assumeCancun,
[ChainId.zkSyncTestNode]: assumeCancun,
},
},
zksyncsepolia: {
url: process.env.ARCHIVE_NODE_zksyncsepolia || "https://sepolia.era.zksync.dev",
Expand All @@ -147,9 +160,9 @@ const config: HardhatUserConfig = {
blockGasLimit: BLOCK_GAS_LIMIT_PER_NETWORK.zksyncmainnet,
zksync: true,
},
zkSyncTestNode: {
zksynctestnode: {
url: process.env.ZKSYNC_ERA_LOCAL_TEST_NODE || "http://localhost:8011",
chainId: 260,
chainId: 300, // change it to 300 for zksyncsepolia
accounts: DEPLOYER_PRIVATE_KEY ? [`0x${DEPLOYER_PRIVATE_KEY}`] : [],
blockGasLimit: BLOCK_GAS_LIMIT_PER_NETWORK.zksyncsepolia,
timeout: 2000000000,
Expand Down
43 changes: 43 additions & 0 deletions multisig/proposals/arbitrumone/vip-018/addresses.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
export const USDT = "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9";
export const USDC = "0xaf88d065e77c8cC2239327C5EDb3A432268e5831";
export const WBTC = "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f";
export const WETH = "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1";
export const PLP = "0x86bf21dB200f29F21253080942Be8af61046Ec29";
export const XVS = "0xc1Eb7689147C81aC840d4FF0D298489fc7986d52";
export const XVS_VAULT_TREASURY = "0xb076D4f15c08D7A7B89466327Ba71bc7e1311b58";

export const Assets = [USDT, USDC, WBTC, WETH, XVS];

export const BaseAssets = [
USDT, // USDTPrimeConverter BaseAsset
USDC, // USDCPrimeConverter BaseAsset
WBTC, // WBTCPrimeConverter BaseAsset
WETH, // WETHPrimeConverter BaseAsset
XVS, // XVSPrimeConverter BaseAsset
];

export const CONVERTER_NETWORK = "0x2F6672C9A0988748b0172D97961BecfD9DC6D6d5";
export const USDT_PRIME_CONVERTER = "0x435Fac1B002d5D31f374E07c0177A1D709d5DC2D";
export const USDC_PRIME_CONVERTER = "0x6553C9f9E131191d4fECb6F0E73bE13E229065C6";
export const WBTC_PRIME_CONVERTER = "0xF91369009c37f029aa28AF89709a352375E5A162";
export const WETH_PRIME_CONVERTER = "0x4aCB90ddD6df24dC6b0D50df84C94e72012026d0";
export const XVS_VAULT_CONVERTER = "0x9c5A7aB705EA40876c1B292630a3ff2e0c213DB1";

export const ACM = "0xD9dD18EB0cf10CbA837677f28A8F9Bda4bc2b157";

export const converters: string[] = [
USDT_PRIME_CONVERTER,
USDC_PRIME_CONVERTER,
WBTC_PRIME_CONVERTER,
WETH_PRIME_CONVERTER,
XVS_VAULT_CONVERTER,
];

// Function to filter assets based on a base asset
const filterAssets = (assets: string[], baseAsset: string) => assets.filter(asset => asset !== baseAsset);

export const USDTPrimeConverterTokenOuts = filterAssets(Assets, BaseAssets[0]);
export const USDCPrimeConverterTokenOuts = filterAssets(Assets, BaseAssets[1]);
export const WBTCPrimeConverterTokenOuts = filterAssets(Assets, BaseAssets[2]);
export const WETHPrimeConverterTokenOuts = filterAssets(Assets, BaseAssets[3]);
export const XVSVaultConverterTokenOuts = filterAssets(Assets, BaseAssets[4]);
102 changes: 102 additions & 0 deletions multisig/proposals/arbitrumone/vip-018/commands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import { NETWORK_ADDRESSES } from "src/networkAddresses";
import { LzChainId } from "src/types";

import { ACM, Assets, CONVERTER_NETWORK, XVS_VAULT_TREASURY, converters } from "./addresses";

const { arbitrumone } = NETWORK_ADDRESSES;

const { NORMAL_TIMELOCK, FAST_TRACK_TIMELOCK, CRITICAL_TIMELOCK, GUARDIAN } = arbitrumone;
const timelocks = [NORMAL_TIMELOCK, FAST_TRACK_TIMELOCK, CRITICAL_TIMELOCK];

type IncentiveAndAccessibility = [number, number];

interface AcceptOwnership {
target: string;
signature: string;
params: [];
}

interface CallPermission {
target: string;
signature: string;
params: [string, string, string];
}

export const grant = (target: string, signature: string, caller: string): CallPermission => {
const config: CallPermission = {
target: ACM,
signature: "giveCallPermission(address,string,address)",
params: [target, signature, caller],
};

return config;
};

const incentiveAndAccessibility: IncentiveAndAccessibility = [0, 1];

function generateAcceptOwnershipCommands(ConvertersArray: string[]): AcceptOwnership[] {
const acceptOwnershipCommandsArray: AcceptOwnership[] = [];

for (const converter of ConvertersArray) {
const config: AcceptOwnership = {
target: converter,
signature: "acceptOwnership()",
params: [],
};

acceptOwnershipCommandsArray.push(config);
}

return acceptOwnershipCommandsArray;
}

const generateSetConverterNetworkCommands = () => {
return converters.map(converter => ({
target: converter,
signature: "setConverterNetwork(address)",
params: [CONVERTER_NETWORK],
}));
};

const generateAddConverterNetworkCommands = () => {
return converters.map(converter => ({
target: CONVERTER_NETWORK,
signature: "addTokenConverter(address)",
params: [converter],
dstChainId: LzChainId.arbitrumone,
}));
};

function generateCallPermissionCommandsOnConverters(convertersArray: string[]): CallPermission[] {
return convertersArray.flatMap(converter => [
...timelocks.flatMap(timelock => [
grant(converter, "setConversionConfig(address,address,ConversionConfig)", timelock),
grant(converter, "pauseConversion()", timelock),
grant(converter, "resumeConversion()", timelock),
grant(converter, "setMinAmountToConvert(uint256)", timelock),
]),
grant(converter, "pauseConversion()", GUARDIAN),
grant(converter, "resumeConversion()", GUARDIAN),
]);
}

function generateCallPermissionCommandsOnMisc(): CallPermission[] {
return timelocks.flatMap(timelock => [
grant(CONVERTER_NETWORK, "addTokenConverter(address)", timelock),
grant(CONVERTER_NETWORK, "removeTokenConverter(address)", timelock),
grant(XVS_VAULT_TREASURY, "fundXVSVault(uint256)", timelock),
]);
}

export const incentiveAndAccessibilities = new Array(Assets.length - 1).fill(incentiveAndAccessibility);

export const acceptOwnershipCommandsAllConverters: AcceptOwnership[] = generateAcceptOwnershipCommands(converters);

export const setConverterNetworkCommands = generateSetConverterNetworkCommands();

export const addConverterNetworkCommands = generateAddConverterNetworkCommands();

export const callPermissionCommands: CallPermission[] = [
...generateCallPermissionCommandsOnConverters(converters),
...generateCallPermissionCommandsOnMisc(),
];
36 changes: 36 additions & 0 deletions multisig/proposals/arbitrumone/vip-018/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { NETWORK_ADDRESSES } from "src/networkAddresses";
import { makeProposal } from "src/utils";

import { ACM, CONVERTER_NETWORK, PLP, USDC, USDT, WBTC, WETH, XVS_VAULT_TREASURY } from "./addresses";
import { acceptOwnershipCommandsAllConverters, callPermissionCommands, setConverterNetworkCommands } from "./commands";

const { arbitrumone } = NETWORK_ADDRESSES;
const vip018 = () => {
return makeProposal([
{
target: PLP,
signature: "initializeTokens(address[])",
params: [[WETH, WBTC, USDC, USDT]],
},
...acceptOwnershipCommandsAllConverters,
{
target: XVS_VAULT_TREASURY,
signature: "acceptOwnership()",
params: [],
},
{
target: CONVERTER_NETWORK,
signature: "acceptOwnership()",
params: [],
},
{
target: ACM,
signature: "giveCallPermission(address,string,address)",
params: [arbitrumone.REDSTONE_ORACLE, "setTokenConfig(TokenConfig)", arbitrumone.GUARDIAN],
},
...callPermissionCommands,
...setConverterNetworkCommands,
]);
};

export default vip018;
Loading

0 comments on commit 722b2be

Please sign in to comment.