Skip to content

Commit

Permalink
fix: rebase errors
Browse files Browse the repository at this point in the history
  • Loading branch information
baroooo committed Dec 18, 2023
1 parent b964126 commit 712b4fd
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 74 deletions.
16 changes: 8 additions & 8 deletions contracts/governance/Airgrab.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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_,
Expand All @@ -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");
Expand All @@ -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_;
Expand All @@ -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");
}
Expand Down Expand Up @@ -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.
Expand All @@ -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);
}
}
13 changes: 6 additions & 7 deletions contracts/governance/GovernanceFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";

/**
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -100,7 +99,7 @@ contract GovernanceFactory is Ownable {
function createGovernance(
address mentoLabsMultiSig_,
address watchdogMultiSig_,
address communityFund_,
address celoCommunityFund_,
bytes32 airgrabRoot,
address fractalSigner
) external onlyOwner {
Expand All @@ -109,7 +108,7 @@ contract GovernanceFactory is Ownable {

mentoLabsMultiSig = mentoLabsMultiSig_;
watchdogMultiSig = watchdogMultiSig_;
communityFund = communityFund_;
celoCommunityFund = celoCommunityFund_;

// Precalculated contract addresses:
address emissionPrecalculated = addressForNonce(2);
Expand Down Expand Up @@ -159,7 +158,7 @@ contract GovernanceFactory is Ownable {
AIRGRAB_LOCK_SLOPE,
tokenPrecalculated,
lockingPrecalculated,
payable(communityFund)
payable(celoCommunityFund)
);
assert(address(airgrab) == airgrabPrecalculated);

Expand Down
6 changes: 3 additions & 3 deletions contracts/governance/deployers/AirgrabDeployerLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -27,7 +27,7 @@ library AirgrabDeployerLib {
uint32 airgrabLockSlope,
address token_,
address locking_,
address payable communityFund_
address payable celoCommunityFund_
) external returns (Airgrab) {
return
new Airgrab(
Expand All @@ -39,7 +39,7 @@ library AirgrabDeployerLib {
airgrabLockSlope,
token_,
locking_,
communityFund_
celoCommunityFund_
);
}
}
27 changes: 0 additions & 27 deletions test/fork-tests/GovernanceFactory.t.sol

This file was deleted.

20 changes: 10 additions & 10 deletions test/governance/Airgrab.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -87,7 +87,7 @@ contract AirgrabTest is Test {
slopePeriod,
tokenAddress,
locking,
communityFund
celoCommunityFund
);
}

Expand All @@ -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
Expand Down Expand Up @@ -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();
}

Expand Down Expand Up @@ -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");

Expand All @@ -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);
}

Expand Down
4 changes: 2 additions & 2 deletions test/governance/GovernanceFactory.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}

// ========================================
Expand Down
34 changes: 17 additions & 17 deletions test/governance/IntegrationTests/Integration.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
_;
}
}

0 comments on commit 712b4fd

Please sign in to comment.