|
| 1 | +import dotenv from "dotenv"; |
| 2 | +dotenv.config(); |
| 3 | +import hre from "hardhat"; |
| 4 | +import {getVerifier} from "./helpers"; |
| 5 | +import {resolveProxyXAddress} from "../test/helpers"; |
| 6 | +import {isSet, assert} from "./common"; |
| 7 | +import {SprinterLiquidityMining} from "../typechain-types"; |
| 8 | +import {networkConfig, Network, NetworkConfig} from "../network.config"; |
| 9 | + |
| 10 | +export async function main() { |
| 11 | + const [deployer] = await hre.ethers.getSigners(); |
| 12 | + |
| 13 | + assert(isSet(process.env.DEPLOY_ID), "DEPLOY_ID must be set"); |
| 14 | + assert(isSet(process.env.UPGRADE_ID), "UPGRADE_ID must be set"); |
| 15 | + const verifier = getVerifier(process.env.UPGRADE_ID); |
| 16 | + console.log(`Deployment ID: ${process.env.DEPLOY_ID}`); |
| 17 | + console.log(`Redeployment ID: ${process.env.UPGRADE_ID}`); |
| 18 | + |
| 19 | + let network: Network; |
| 20 | + let config: NetworkConfig; |
| 21 | + console.log(`Redeploying to: ${hre.network.name}`); |
| 22 | + if (hre.network.name === "hardhat" && Object.values(Network).includes(process.env.DRY_RUN as Network)) { |
| 23 | + network = process.env.DRY_RUN as Network; |
| 24 | + config = networkConfig[network]; |
| 25 | + console.log(`Dry run on fork: ${network}`); |
| 26 | + } else if (Object.values(Network).includes(hre.network.name as Network)) { |
| 27 | + network = hre.network.name as Network; |
| 28 | + config = networkConfig[network]; |
| 29 | + } else { |
| 30 | + console.log(`Nothing to redeploy on ${hre.network.name} network`); |
| 31 | + return; |
| 32 | + } |
| 33 | + |
| 34 | + assert(config.Hub, "Must be a network with a hub"); |
| 35 | + |
| 36 | + const liquidityHub = await resolveProxyXAddress("LiquidityHub"); |
| 37 | + |
| 38 | + const tiers = config.Hub!.Tiers; |
| 39 | + const liquidityMining = ( |
| 40 | + await verifier.deployX("SprinterLiquidityMining", deployer, {}, [config.Admin, liquidityHub, tiers]) |
| 41 | + ) as SprinterLiquidityMining; |
| 42 | + |
| 43 | + console.log(`Admin: ${config.Admin}`); |
| 44 | + console.log(`SprinterLiquidityMining: ${liquidityMining.target}`); |
| 45 | + console.log("Tiers:"); |
| 46 | + console.table(tiers.map(el => { |
| 47 | + const multiplier = `${el.multiplier / 1000000000n}.${el.multiplier % 1000000000n}x`; |
| 48 | + return {seconds: Number(el.period), multiplier}; |
| 49 | + })); |
| 50 | + |
| 51 | + await verifier.verify(process.env.VERIFY === "true"); |
| 52 | +} |
| 53 | + |
| 54 | +if (process.env.SCRIPT_ENV !== "CI") { |
| 55 | + main(); |
| 56 | +} |
0 commit comments