UNPKG

@dydxfoundation/governance

Version:
94 lines (93 loc) 4.29 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.getDeployConfig = void 0; const luxon_1 = require("luxon"); const config_1 = __importDefault(require("../config")); const constants_1 = require("../lib/constants"); const base_config_1 = __importDefault(require("./base-config")); const hardhat_config_1 = __importDefault(require("./hardhat-config")); const mainnet_fork_config_1 = __importDefault(require("./mainnet-fork-config")); const mainnet_phase_1_config_1 = __importDefault(require("./mainnet-phase-1-config")); const mainnet_phase_2_config_1 = __importDefault(require("./mainnet-phase-2-config")); /** * Get the deployment config. * * Must be wrapped in a function so that it can be evaluated after hardhat has been configured. */ function getDeployConfig({ getOldMainnetPhase1 = false, getOldMainnetPhase2 = false, } = {}) { // Copy the base config. const deployConfig = { ...base_config_1.default, }; // Override parameters depending on the environment or deployment phase. This must include // setting the epoch zero start time, from which the rest of the schedule is derived. // // Note: Many contracts are not deployable unless the epoch zero start time is in the future. if (getOldMainnetPhase1) { Object.assign(deployConfig, mainnet_phase_1_config_1.default); } else if (getOldMainnetPhase2) { Object.assign(deployConfig, mainnet_phase_2_config_1.default); } else if (config_1.default.isHardhat()) { if (config_1.default.FORK_MAINNET) { Object.assign(deployConfig, mainnet_fork_config_1.default); } else { Object.assign(deployConfig, hardhat_config_1.default); } } else if (config_1.default.isMainnet()) { Object.assign(deployConfig, mainnet_phase_2_config_1.default); } else { // Need to add a new configuration file to set the value of EPOCH_ZERO_START. throw new Error('Deployment configuration is not known for this network.'); } if (!deployConfig.EPOCH_ZERO_START) { throw new Error('EPOCH_ZERO_START was not set'); } // Below: Derive all parameters which depend on the epoch zero start time. const TRANSFERS_RESTRICTED_BEFORE = (deployConfig.EPOCH_ZERO_START + deployConfig.EPOCH_LENGTH + deployConfig.MERKLE_DISTRIBUTOR_WAITING_PERIOD + constants_1.ONE_DAY_SECONDS); const REWARDS_TREASURY_VESTER_CONFIG = { VESTING_AMOUNT: deployConfig.REWARDS_TREASURY_VESTING_AMOUNT, VESTING_BEGIN: deployConfig.EPOCH_ZERO_START, VESTING_CLIFF: deployConfig.EPOCH_ZERO_START, VESTING_END: addFiveYears(deployConfig.EPOCH_ZERO_START), }; const COMMUNITY_TREASURY_VESTER_CONFIG = { VESTING_AMOUNT: deployConfig.COMMUNITY_TREASURY_VESTING_AMOUNT, VESTING_BEGIN: deployConfig.EPOCH_ZERO_START, VESTING_CLIFF: deployConfig.EPOCH_ZERO_START, VESTING_END: addFiveYears(deployConfig.EPOCH_ZERO_START), }; return { ...deployConfig, // Token schedule parameters. EPOCH_ZERO_START: deployConfig.EPOCH_ZERO_START, TRANSFERS_RESTRICTED_BEFORE, TRANSFER_RESTRICTION_LIFTED_NO_LATER_THAN: TRANSFERS_RESTRICTED_BEFORE + 30 * constants_1.ONE_DAY_SECONDS, MINTING_RESTRICTED_BEFORE: addFiveYears(TRANSFERS_RESTRICTED_BEFORE), // Staking schedule parameters. LS_DISTRIBUTION_START: deployConfig.EPOCH_ZERO_START, LS_DISTRIBUTION_END: deployConfig.EPOCH_ZERO_START + deployConfig.REWARDS_DISTRIBUTION_LENGTH, SM_DISTRIBUTION_START: TRANSFERS_RESTRICTED_BEFORE, SM_DISTRIBUTION_END: TRANSFERS_RESTRICTED_BEFORE + deployConfig.REWARDS_DISTRIBUTION_LENGTH, // Treasury parameters. REWARDS_TREASURY_VESTER_CONFIG, COMMUNITY_TREASURY_VESTER_CONFIG, }; } exports.getDeployConfig = getDeployConfig; /** * Add five years to a timestamp. This adds (365 * 5) days plus 1 day for the leap year. */ function addFiveYears(timestamp) { return luxon_1.DateTime.fromSeconds(timestamp).plus({ years: 5 }).toSeconds(); }