diff --git a/contracts/AdhocVoter.sol b/contracts/AdhocVoter.sol index c8f86a8..30a27a6 100644 --- a/contracts/AdhocVoter.sol +++ b/contracts/AdhocVoter.sol @@ -6,6 +6,7 @@ import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import {IAdhocVoter} from "./interfaces/IAdhocVoter.sol"; +import {IIncentive} from "./interfaces/IIncentive.sol"; import {IGauge} from "./interfaces/IGauge.sol"; import {IStrategyManager} from "./interfaces/IStrategyManager.sol"; import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; @@ -34,6 +35,10 @@ contract AdhocVoter is IAdhocVoter, Initializable { weekly = 100_000 * 1e18; } + function isAlive(address) external override pure returns (bool) { + return true; + } + function setGovernor(address _governor) public { require(msg.sender == governor, "Not Governor"); require (_governor != address(0), "ZeroAddress"); @@ -72,13 +77,14 @@ contract AdhocVoter is IAdhocVoter, Initializable { emit WeeklyChanged(_weekly); } - function addGauge(address _gauge, uint256 _weight) external { + function addGauge(address _gauge, address _incentive, uint256 _weight) external { require(_weight >= 10 && _weight <= 100, "invalid weight"); require(msg.sender == governor, "Not Governor"); require(!gauges.contains(_gauge), "gauge already exist"); weights[_gauge] = _weight; totalWeight += _weight; + IIncentive(_incentive).setGauge(_gauge); emit WeightChanged(_gauge, _weight); } diff --git a/contracts/interfaces/IAdhocVoter.sol b/contracts/interfaces/IAdhocVoter.sol index c83ac89..d7c268e 100644 --- a/contracts/interfaces/IAdhocVoter.sol +++ b/contracts/interfaces/IAdhocVoter.sol @@ -27,6 +27,9 @@ interface IAdhocVoter { /// @notice Number of epochs in which updatePeriod was called function epochCount() external view returns (uint256); + /// @dev Gauge => Liveness status + function isAlive(address gauge) external view returns (bool); + /// @notice Processes emissions and rebases. Callable once per epoch (1 week). /// @return _period Start of current epoch. function emitReward() external returns (uint256 _period); @@ -47,8 +50,9 @@ interface IAdhocVoter { /// @notice Add new gauge; /// @param _gauge . + /// @param _incentive . /// @param _weight for _gauge - function addGauge(address _gauge, uint256 _weight) external; + function addGauge(address _gauge, address _incentive, uint256 _weight) external; /// @notice change weight of the gauge /// @param _gauge . diff --git a/script/08_deploy_taxgauge_voter.ts b/script/08_deploy_taxgauge_voter.ts index d24a117..a651f84 100644 --- a/script/08_deploy_taxgauge_voter.ts +++ b/script/08_deploy_taxgauge_voter.ts @@ -1,15 +1,11 @@ -import {ethers, upgrades} from 'hardhat'; -import fs from "fs"; +import { ethers, upgrades } from 'hardhat'; +import fs from 'fs'; require('dotenv').config(); // npx hardhat run script/08_deploy_taxgauge_voter.ts --network testnet async function main() { if (!process.env.FORWARDER) { - console.log(`Please provide VOTER address`); - return; - } - if (!process.env.DeviceNFT) { - console.log(`Please provide EMPTY_FACTORY address`); + console.log(`Please provide FORWARDER address`); return; } @@ -20,19 +16,31 @@ async function main() { await adhocVoter.waitForDeployment(); console.log(`AdhocVoter deployed to ${adhocVoter.target}`); - const incentive = await ethers.deployContract('Incentives', [ - process.env.FORWARDER, adhocVoter.target, []]); + const incentive = await ethers.deployContract('Incentives', [process.env.FORWARDER, adhocVoter.target, []]); await incentive.waitForDeployment(); console.log(`Incentive deployed to ${incentive.target}`); - const deviceNFTToken = await ethers.deployContract('TestDeviceNFT', ["DeviceNFT", "TestNFT"]) - await deviceNFTToken.waitForDeployment(); - console.log(`TestToken deployed to ${deviceNFTToken.target}`); + let deviceNFT = process.env.DEVICE_NFT; + + if (!deviceNFT) { + const deviceNFTToken = await ethers.deployContract('TestDeviceNFT', ['DeviceNFT', 'TestNFT']); + await deviceNFTToken.waitForDeployment(); + // @ts-ignore + deviceNFT = deviceNFTToken.target; + console.log(`TestToken deployed to ${deviceNFTToken.target}`); + } const taxDeviceGauge = await ethers.deployContract('TaxDeviceGauge', [ - process.env.FORWARDER, deviceNFTToken.target, adhocVoter.target, incentive.target]); + process.env.FORWARDER, + deviceNFT, + adhocVoter.target, + incentive.target, + ]); await taxDeviceGauge.waitForDeployment(); console.log(`taxDeviceGauge deployed to ${taxDeviceGauge.target}`); + + const tx = await adhocVoter.addGauge(taxDeviceGauge.target, incentive.target, 100); + await tx.wait(); } main().catch(err => {