"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const hardhat_1 = require("hardhat");
const deploymentConfig_1 = require("../helpers/deploymentConfig");
const func = async function (hre) {
    const { deployments, getNamedAccounts } = hre;
    const { deployer } = await getNamedAccounts();
    const isTimeBased = false; // configure this value if time based deployment
    const blocksPerYear = {
        bsctestnet: 10512000,
        sepolia: 2628000,
        arbitrumsepolia: 0,
        opsepolia: 0,
        opmainnet: 0,
        arbitrumone: 0,
        zksyncsepolia: 0,
        zksyncmainnet: 0,
        unichainsepolia: 0,
        bscmainnet: 10512000,
        ethereum: 2628000,
        basesepolia: 0,
        basemainnet: 0,
        hardhat: 100,
    };
    const adminAccount = {
        sepolia: "0x94fa6078b6b8a26f0b6edffbe6501b22a10470fb",
        ethereum: "0x285960C5B22fD66A736C7136967A3eB15e93CC67",
        opbnbtestnet: "0xb15f6EfEbC276A3b9805df81b5FB3D50C2A62BDf",
        opbnbmainnet: "0xC46796a21a3A9FAB6546aF3434F2eBfFd0604207",
        arbitrumsepolia: "0x1426A5Ae009c4443188DA8793751024E358A61C2",
        arbitrumone: "0x14e0E151b33f9802b3e75b621c1457afc44DcAA0",
        zksyncsepolia: "0xa2f83de95E9F28eD443132C331B6a9C9B7a9F866",
        zksyncmainnet: "0x751Aa759cfBB6CE71A43b48e40e1cCcFC66Ba4aa",
        opsepolia: "0xd57365EE4E850e881229e2F8Aa405822f289e78d",
        opmainnet: "0x2e94dd14E81999CdBF5deDE31938beD7308354b3",
        unichainsepolia: "0x9831D3A641E8c7F082EEA75b8249c99be9D09a34",
        bscmainnet: await (0, deploymentConfig_1.getContractAddressOrNullAddress)(deployments, "NormalTimelock"),
        bsctestnet: await (0, deploymentConfig_1.getContractAddressOrNullAddress)(deployments, "NormalTimelock"),
        basesepolia: "0xdf3b635d2b535f906BB02abb22AED71346E36a00",
        basemainnet: "0x1803Cf1D3495b43cC628aa1d8638A981F8CD341C",
        hardhat: deployer,
    };
    const accessControlManager = await hardhat_1.ethers.getContract("AccessControlManager");
    const xvs = await hardhat_1.ethers.getContract("XVS");
    const xvsVaultProxyDeployment = await hardhat_1.ethers.getContract("XVSVaultProxy");
    const xvsStoreDeployment = await hardhat_1.ethers.getContract("XVSStore");
    let xvsVault = await hardhat_1.ethers.getContract("XVSVaultProxy_Implementation");
    await xvsVaultProxyDeployment._setPendingImplementation(xvsVault.address);
    await xvsVault._become(xvsVaultProxyDeployment.address);
    xvsVault = await hardhat_1.ethers.getContractAt("XVSVault", xvsVaultProxyDeployment.address);
    let txn = await xvsVault.initializeTimeManager(isTimeBased, blocksPerYear[hardhat_1.network.name]);
    await txn.wait();
    txn = await xvsVault.setXvsStore(xvs.address, xvsStoreDeployment.address);
    await txn.wait();
    txn = await xvsVault.setAccessControl(accessControlManager.address);
    await txn.wait();
    await xvsStoreDeployment.setNewOwner(xvsVaultProxyDeployment.address);
    if (!hre.network.live) {
        const tx = await accessControlManager.giveCallPermission(hardhat_1.ethers.constants.AddressZero, "add(address,uint256,address,uint256,uint256)", deployer);
        await tx.wait();
        // Add token pool to xvs vault
        const allocPoint = 100;
        const token = xvs.address;
        const rewardToken = xvs.address;
        const rewardPerBlock = "61805555555555555";
        const lockPeriod = 604800;
        await xvsVault.add(rewardToken, allocPoint, token, rewardPerBlock, lockPeriod);
    }
    else {
        const owner = adminAccount[hre.network.name];
        console.log("Please accept ownership of vault and store");
        txn = await xvsVaultProxyDeployment._setPendingAdmin(owner);
        await txn.wait();
        txn = await xvsStoreDeployment.setPendingAdmin(owner);
        await txn.wait();
    }
};
func.tags = ["xvs-vault"];
func.id = "xvs_vault_configuration"; // id required to prevent re-execution
exports.default = func;
