From 712b4fd17210886fca7d8b733bb7e72866f987cc Mon Sep 17 00:00:00 2001 From: baroooo Date: Mon, 18 Dec 2023 14:34:45 +0100 Subject: [PATCH] fix: rebase errors --- contracts/governance/Airgrab.sol | 16 ++++----- contracts/governance/GovernanceFactory.sol | 13 ++++--- .../deployers/AirgrabDeployerLib.sol | 6 ++-- test/fork-tests/GovernanceFactory.t.sol | 27 --------------- test/governance/Airgrab.t.sol | 20 +++++------ test/governance/GovernanceFactory.t.sol | 4 +-- .../IntegrationTests/Integration.t.sol | 34 +++++++++---------- 7 files changed, 46 insertions(+), 74 deletions(-) delete mode 100644 test/fork-tests/GovernanceFactory.t.sol diff --git a/contracts/governance/Airgrab.sol b/contracts/governance/Airgrab.sol index 7ffecf4..0c9e675 100644 --- a/contracts/governance/Airgrab.sol +++ b/contracts/governance/Airgrab.sol @@ -58,8 +58,8 @@ contract Airgrab is ReentrancyGuard { IERC20 public immutable token; /// @notice The locking contract for veToken. ILocking public immutable locking; - /// @notice The community fund address where the tokens will be refunded. - address payable public immutable communityFund; + /// @notice The Celo community fund address where unclaimed tokens will be refunded to. + address payable public immutable celoCommunityFund; /// @notice The map of addresses that have claimed mapping(address => bool) public claimed; @@ -144,7 +144,7 @@ contract Airgrab is ReentrancyGuard { * @param slopePeriod_ The slope period that the airgrab will be locked for. * @param token_ The token address in the airgrab. * @param locking_ The locking contract for veToken. - * @param communityFund_ The community fund address where the tokens will be refunded. + * @param celoCommunityFund_ The Celo community fund address where unclaimed tokens will be refunded to. */ constructor( bytes32 root_, @@ -155,7 +155,7 @@ contract Airgrab is ReentrancyGuard { uint32 slopePeriod_, address token_, address locking_, - address payable communityFund_ + address payable celoCommunityFund_ ) { require(root_ != bytes32(0), "Airgrab: invalid root"); require(fractalSigner_ != address(0), "Airgrab: invalid fractal issuer"); @@ -165,7 +165,7 @@ contract Airgrab is ReentrancyGuard { require(slopePeriod_ <= MAX_SLOPE_PERIOD, "Airgrab: slope period too large"); require(token_ != address(0), "Airgrab: invalid token"); require(locking_ != address(0), "Airgrab: invalid locking"); - require(communityFund_ != address(0), "Airgrab: invalid community fund"); + require(celoCommunityFund_ != address(0), "Airgrab: invalid celo community fund"); root = root_; fractalSigner = fractalSigner_; @@ -175,7 +175,7 @@ contract Airgrab is ReentrancyGuard { slopePeriod = slopePeriod_; token = IERC20(token_); locking = ILocking(locking_); - communityFund = communityFund_; + celoCommunityFund = celoCommunityFund_; require(token.approve(locking_, type(uint256).max), "Airgrab: approval failed"); } @@ -216,7 +216,7 @@ contract Airgrab is ReentrancyGuard { } /** - * @dev Allows the community fund to reclaim any tokens after the airgrab has ended. + * @dev Allows the Celo community fund to reclaim any tokens after the airgrab has ended. * @notice This function can only be called after the airgrab has ended. * @param tokenToDrain Token is parameterized in case the contract has been sent * tokens other than the airgrab token. @@ -226,7 +226,7 @@ contract Airgrab is ReentrancyGuard { require(block.timestamp > endTimestamp, "Airgrab: not finished"); uint256 balance = IERC20(tokenToDrain).balanceOf(address(this)); require(balance > 0, "Airgrab: nothing to drain"); - IERC20(tokenToDrain).safeTransfer(communityFund, balance); + IERC20(tokenToDrain).safeTransfer(celoCommunityFund, balance); emit TokensDrained(tokenToDrain, balance); } } diff --git a/contracts/governance/GovernanceFactory.sol b/contracts/governance/GovernanceFactory.sol index 48f19b3..3bf68de 100644 --- a/contracts/governance/GovernanceFactory.sol +++ b/contracts/governance/GovernanceFactory.sol @@ -21,7 +21,6 @@ import { TransparentUpgradeableProxy } from "openzeppelin-contracts-next/contrac import { ProxyAdmin } from "openzeppelin-contracts-next/contracts/proxy/transparent/ProxyAdmin.sol"; import { Ownable } from "openzeppelin-contracts-next/contracts/access/Ownable.sol"; -import { IVotesUpgradeable } from "openzeppelin-contracts-upgradeable/contracts/governance/extensions/GovernorVotesUpgradeable.sol"; import { IERC20Upgradeable } from "openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol"; /** @@ -55,7 +54,7 @@ contract GovernanceFactory is Ownable { address public mentoLabsMultiSig; address public watchdogMultiSig; - address public communityFund; + address public celoCommunityFund; // Indicates if the governance system has been created bool public initialized; @@ -90,8 +89,8 @@ contract GovernanceFactory is Ownable { /** * @notice Creates and initializes the governance system contracts * @param mentoLabsMultiSig_ Address of the Mento Labs multisig from where the team allocation will be vested - * @param watchdogMultiSig_ Address of the community's multisig wallet with the veto rights - * @param communityFund_ Address of the community fund that will receive the unclaimed airgrab tokens + * @param watchdogMultiSig_ Address of the Mento community's multisig wallet with the veto rights + * @param celoCommunityFund_ Address of the Celo community fund that will receive the unclaimed airgrab tokens * @param airgrabRoot Root hash for the airgrab Merkle tree * @param fractalSigner Signer of fractal kyc * @dev Can only be called by the owner and only once @@ -100,7 +99,7 @@ contract GovernanceFactory is Ownable { function createGovernance( address mentoLabsMultiSig_, address watchdogMultiSig_, - address communityFund_, + address celoCommunityFund_, bytes32 airgrabRoot, address fractalSigner ) external onlyOwner { @@ -109,7 +108,7 @@ contract GovernanceFactory is Ownable { mentoLabsMultiSig = mentoLabsMultiSig_; watchdogMultiSig = watchdogMultiSig_; - communityFund = communityFund_; + celoCommunityFund = celoCommunityFund_; // Precalculated contract addresses: address emissionPrecalculated = addressForNonce(2); @@ -159,7 +158,7 @@ contract GovernanceFactory is Ownable { AIRGRAB_LOCK_SLOPE, tokenPrecalculated, lockingPrecalculated, - payable(communityFund) + payable(celoCommunityFund) ); assert(address(airgrab) == airgrabPrecalculated); diff --git a/contracts/governance/deployers/AirgrabDeployerLib.sol b/contracts/governance/deployers/AirgrabDeployerLib.sol index cee2791..e0cf002 100644 --- a/contracts/governance/deployers/AirgrabDeployerLib.sol +++ b/contracts/governance/deployers/AirgrabDeployerLib.sol @@ -15,7 +15,7 @@ library AirgrabDeployerLib { * @param airgrabLockSlope The slope duration for the airgrabed tokens in weeks * @param token_ The token address in the airgrab. * @param locking_ The locking contract for veToken. - * @param communityFund_ The community fund address where unclaimed tokens will be refunded to. + * @param celoCommunityFund_ The Celo community fund address where unclaimed tokens will be refunded to. * @return Airgrab The address of the new Airgrab contract */ function deploy( @@ -27,7 +27,7 @@ library AirgrabDeployerLib { uint32 airgrabLockSlope, address token_, address locking_, - address payable communityFund_ + address payable celoCommunityFund_ ) external returns (Airgrab) { return new Airgrab( @@ -39,7 +39,7 @@ library AirgrabDeployerLib { airgrabLockSlope, token_, locking_, - communityFund_ + celoCommunityFund_ ); } } diff --git a/test/fork-tests/GovernanceFactory.t.sol b/test/fork-tests/GovernanceFactory.t.sol deleted file mode 100644 index 10a10d0..0000000 --- a/test/fork-tests/GovernanceFactory.t.sol +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-or-later -pragma solidity 0.8.18; -// solhint-disable func-name-mixedcase - -import { BaseTest } from "../utils/BaseTest.next.sol"; -import { GovernanceFactory } from "contracts/governance/GovernanceFactory.sol"; - -contract GovernanceFactoryForkTest is BaseTest { - string public constant NETWORK_CELO_RPC = "celo_mainnet"; - string public constant NETWORK_ALFAJORES_RPC = "alfajores"; - - function setUp() public { - uint256 forkId = vm.createFork(NETWORK_CELO_RPC); - vm.selectFork(forkId); - } - - function test_createGovernance() public { - GovernanceFactory factory = new GovernanceFactory(address(this)); - factory.createGovernance( - makeAddr("MentoLabsMultiSig"), - makeAddr("WatchdogMultiSig"), - makeAddr("CommunityFund"), - keccak256(abi.encodePacked("FakeRoot")), - makeAddr("FractalSigner") - ); - } -} diff --git a/test/governance/Airgrab.t.sol b/test/governance/Airgrab.t.sol index 7276df5..e36f3fe 100644 --- a/test/governance/Airgrab.t.sol +++ b/test/governance/Airgrab.t.sol @@ -38,7 +38,7 @@ contract AirgrabTest is Test { Airgrab public airgrab; ERC20 public token; - address payable public communityFund = payable(makeAddr("CommunityFund")); + address payable public celoCommunityFund = payable(makeAddr("CeloCommunityFund")); address public fractalSigner; uint256 public fractalSignerPk; uint256 public otherSignerPk; @@ -87,7 +87,7 @@ contract AirgrabTest is Test { slopePeriod, tokenAddress, locking, - communityFund + celoCommunityFund ); } @@ -113,7 +113,7 @@ contract AirgrabTest is Test { assertEq(airgrab.slopePeriod(), slopePeriod); assertEq(address(airgrab.token()), tokenAddress); assertEq(address(airgrab.locking()), locking); - assertEq(address(airgrab.communityFund()), communityFund); + assertEq(address(airgrab.celoCommunityFund()), celoCommunityFund); } /// @notice Checks the merke root @@ -158,10 +158,10 @@ contract AirgrabTest is Test { c_subject(); } - /// @notice Checks the community fund address - function test_Constructor_whenInvalidjommunityFund_reverts() public { - communityFund = payable(address(0)); - vm.expectRevert("Airgrab: invalid community fund"); + /// @notice Checks the Celo community fund address + function test_Constructor_whenInvalidCeloCommunityFund_reverts() public { + celoCommunityFund = payable(address(0)); + vm.expectRevert("Airgrab: invalid celo community fund"); c_subject(); } @@ -213,11 +213,11 @@ contract AirgrabTest is Test { vm.expectEmit(true, true, true, true); emit TokensDrained(tokenAddress, 100e18); airgrab.drain(tokenAddress); - assertEq(token.balanceOf(communityFund), 100e18); + assertEq(token.balanceOf(celoCommunityFund), 100e18); assertEq(token.balanceOf(address(airgrab)), 0); } - /// @notice Drains all arbitrary tokens to the community fund if the airgrab has ended + /// @notice Drains all arbitrary tokens to the Celo community fund if the airgrab has ended function test_Drain_drainsOtherTokens() public d_setUp { ERC20 otherToken = new ERC20("Other Token", "OTT"); @@ -228,7 +228,7 @@ contract AirgrabTest is Test { emit TokensDrained(address(otherToken), 100e18); airgrab.drain(address(otherToken)); - assertEq(otherToken.balanceOf(communityFund), 100e18); + assertEq(otherToken.balanceOf(celoCommunityFund), 100e18); assertEq(otherToken.balanceOf(address(airgrab)), 0); } diff --git a/test/governance/GovernanceFactory.t.sol b/test/governance/GovernanceFactory.t.sol index 5b71721..77210e7 100644 --- a/test/governance/GovernanceFactory.t.sol +++ b/test/governance/GovernanceFactory.t.sol @@ -16,7 +16,7 @@ contract GovernanceFactoryTest is TestSetup { address public mentoLabsMultiSig = makeAddr("MentoLabsVestingMultisig"); address public watchdogMultiSig = makeAddr("WatchdogMultisig"); - address public communityFund = makeAddr("CommunityFund"); + address public celoCommunityFund = makeAddr("CeloCommunityFund"); address public fractalSigner = makeAddr("FractalSigner"); bytes32 public airgrabMerkleRoot = 0x945d83ced94efc822fed712b4c4694b4e1129607ec5bbd2ab971bb08dca4d809; // Mock root @@ -34,7 +34,7 @@ contract GovernanceFactoryTest is TestSetup { } function _createGovernance() internal { - factory.createGovernance(mentoLabsMultiSig, watchdogMultiSig, communityFund, airgrabMerkleRoot, fractalSigner); + factory.createGovernance(mentoLabsMultiSig, watchdogMultiSig, celoCommunityFund, airgrabMerkleRoot, fractalSigner); } // ======================================== diff --git a/test/governance/IntegrationTests/Integration.t.sol b/test/governance/IntegrationTests/Integration.t.sol index 1c21b71..74f7893 100644 --- a/test/governance/IntegrationTests/Integration.t.sol +++ b/test/governance/IntegrationTests/Integration.t.sol @@ -500,23 +500,6 @@ contract GovernanceIntegrationTest is TestSetup, Proposals, Utils { mentoGovernor.execute(targets, values, calldatas, keccak256(bytes(description))); } - modifier s_governance() { - vm.prank(governanceTimelockAddress); - mentoToken.transfer(alice, 10_000e18); - - vm.prank(governanceTimelockAddress); - mentoToken.transfer(bob, 10_000e18); - - vm.prank(alice); - locking.lock(alice, alice, 2000e18, 1, 103); - - vm.prank(bob); - locking.lock(bob, bob, 1500e18, 1, 103); - - Utils._timeTravel(BLOCKS_DAY); - _; - } - function test_governor_propose_whenExecutedForImplementationUpgrade_shouldUpgradeTheContracts() public s_governance { // create new implementations TestLocking newLockingContract = new TestLocking(); @@ -843,4 +826,21 @@ contract GovernanceIntegrationTest is TestSetup, Proposals, Utils { // the balance is not updated assertEq(mentoToken.balanceOf(address(mentoLabsTreasury)), 120_000_000 * 10**18); } + + modifier s_governance() { + vm.prank(governanceTimelockAddress); + mentoToken.transfer(alice, 10_000e18); + + vm.prank(governanceTimelockAddress); + mentoToken.transfer(bob, 10_000e18); + + vm.prank(alice); + locking.lock(alice, alice, 2000e18, 1, 103); + + vm.prank(bob); + locking.lock(bob, bob, 1500e18, 1, 103); + + Utils._timeTravel(BLOCKS_DAY); + _; + } }