Skip to content

Commit

Permalink
feat: update airdrop refund address to Mento Treasury (#402)
Browse files Browse the repository at this point in the history
  • Loading branch information
philbow61 authored Apr 3, 2024
1 parent 8713527 commit b9c8ae1
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 36 deletions.
16 changes: 8 additions & 8 deletions contracts/governance/Airgrab.sol
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ contract Airgrab is ReentrancyGuard {
IERC20 public immutable token;
/// @notice The locking contract for veToken.
ILocking public immutable locking;
/// @notice The Celo community fund address where unclaimed tokens will be refunded to.
address payable public immutable celoCommunityFund;
/// @notice The Mento Treasury address where unclaimed tokens will be refunded to.
address payable public immutable mentoTreasury;

/// @notice The map of addresses that have claimed
mapping(address => bool) public claimed;
Expand Down Expand Up @@ -136,7 +136,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 celoCommunityFund_ The Celo community fund address where unclaimed tokens will be refunded to.
* @param mentoTreasury_ The Mento Treasury address where unclaimed tokens will be refunded to.
*/
constructor(
bytes32 root_,
Expand All @@ -147,7 +147,7 @@ contract Airgrab is ReentrancyGuard {
uint32 slopePeriod_,
address token_,
address locking_,
address payable celoCommunityFund_
address payable mentoTreasury_
) {
require(root_ != bytes32(0), "Airgrab: invalid root");
require(fractalSigner_ != address(0), "Airgrab: invalid fractal issuer");
Expand All @@ -156,7 +156,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(celoCommunityFund_ != address(0), "Airgrab: invalid celo community fund");
require(mentoTreasury_ != address(0), "Airgrab: invalid Mento Treasury");

root = root_;
fractalSigner = fractalSigner_;
Expand All @@ -166,7 +166,7 @@ contract Airgrab is ReentrancyGuard {
slopePeriod = slopePeriod_;
token = IERC20(token_);
locking = ILocking(locking_);
celoCommunityFund = celoCommunityFund_;
mentoTreasury = mentoTreasury_;

require(token.approve(locking_, type(uint256).max), "Airgrab: approval failed");
}
Expand Down Expand Up @@ -207,7 +207,7 @@ contract Airgrab is ReentrancyGuard {
}

/**
* @dev Allows the Celo community fund to reclaim any tokens after the airgrab has ended.
* @dev Allows the Mento Treasury 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 @@ -216,7 +216,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(celoCommunityFund, balance);
IERC20(tokenToDrain).safeTransfer(mentoTreasury, balance);
emit TokensDrained(tokenToDrain, balance);
}
}
7 changes: 1 addition & 6 deletions contracts/governance/GovernanceFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ contract GovernanceFactory is Ownable {
Locking public locking;

address public watchdogMultiSig;
address public celoCommunityFund;

// Indicates if the governance system has been created
bool public initialized;
Expand Down Expand Up @@ -93,7 +92,6 @@ contract GovernanceFactory is Ownable {
/**
* @notice Creates and initializes the governance system contracts
* @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
* @param allocationParams Parameters for the initial token allocation
Expand All @@ -102,7 +100,6 @@ contract GovernanceFactory is Ownable {
// solhint-disable-next-line function-max-lines
function createGovernance(
address watchdogMultiSig_,
address celoCommunityFund_,
bytes32 airgrabRoot,
address fractalSigner,
MentoTokenAllocationParams calldata allocationParams
Expand All @@ -112,8 +109,6 @@ contract GovernanceFactory is Ownable {

// slither-disable-next-line missing-zero-check
watchdogMultiSig = watchdogMultiSig_;
// slither-disable-next-line missing-zero-check
celoCommunityFund = celoCommunityFund_;

// Precalculated contract addresses:
address tokenPrecalculated = addressForNonce(2);
Expand Down Expand Up @@ -190,7 +185,7 @@ contract GovernanceFactory is Ownable {
AIRGRAB_LOCK_SLOPE,
tokenPrecalculated,
lockingPrecalculated,
payable(celoCommunityFund)
payable(governanceTimelockPrecalculated)
);
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 celoCommunityFund_ The Celo community fund address where unclaimed tokens will be refunded to.
* @param mentoTreasury_ The Mento Treasury 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 celoCommunityFund_
address payable mentoTreasury_
) external returns (Airgrab) {
return
new Airgrab(
Expand All @@ -39,7 +39,7 @@ library AirgrabDeployerLib {
airgrabLockSlope,
token_,
locking_,
celoCommunityFund_
mentoTreasury_
);
}
}
22 changes: 11 additions & 11 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 celoCommunityFund = payable(makeAddr("CeloCommunityFund"));
address payable public mentoTreasury = payable(makeAddr("MentoTreasury"));
address public fractalSigner;
uint256 public fractalSignerPk;
uint256 public otherSignerPk;
Expand Down Expand Up @@ -87,7 +87,7 @@ contract AirgrabTest is Test {
slopePeriod,
tokenAddress,
locking,
celoCommunityFund
mentoTreasury
);
}

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.celoCommunityFund()), celoCommunityFund);
assertEq(address(airgrab.mentoTreasury()), mentoTreasury);
}

/// @notice Checks the merke root
Expand Down Expand Up @@ -158,10 +158,10 @@ contract AirgrabTest is Test {
c_subject();
}

/// @notice Checks the Celo community fund address
function test_Constructor_whenInvalidCeloCommunityFund_reverts() public {
celoCommunityFund = payable(address(0));
vm.expectRevert("Airgrab: invalid celo community fund");
/// @notice Checks the Mento Treasury address
function test_Constructor_whenInvalidMentoTreasury_reverts() public {
mentoTreasury = payable(address(0));
vm.expectRevert("Airgrab: invalid Mento Treasury");
c_subject();
}

Expand Down Expand Up @@ -206,18 +206,18 @@ contract AirgrabTest is Test {
airgrab.drain(tokenAddress);
}

/// @notice Drains all tokens to the community fund if the airgrab has ended
/// @notice Drains all tokens to the Mento Treasury if the airgrab has ended
function test_Drain_drains() public d_setUp {
vm.warp(airgrab.endTimestamp() + 1);
deal(tokenAddress, address(airgrab), 100e18);
vm.expectEmit(true, true, true, true);
emit TokensDrained(tokenAddress, 100e18);
airgrab.drain(tokenAddress);
assertEq(token.balanceOf(celoCommunityFund), 100e18);
assertEq(token.balanceOf(mentoTreasury), 100e18);
assertEq(token.balanceOf(address(airgrab)), 0);
}

/// @notice Drains all arbitrary tokens to the Celo community fund if the airgrab has ended
/// @notice Drains all arbitrary tokens to the Mento Treasury 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(celoCommunityFund), 100e18);
assertEq(otherToken.balanceOf(mentoTreasury), 100e18);
assertEq(otherToken.balanceOf(address(airgrab)), 0);
}

Expand Down
5 changes: 2 additions & 3 deletions test/governance/GovernanceFactory.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ contract GovernanceFactoryTest is TestSetup {

address public mentoLabsMultiSig = makeAddr("MentoLabsVestingMultisig");
address public watchdogMultiSig = makeAddr("WatchdogMultisig");
address public celoCommunityFund = makeAddr("CeloCommunityFund");
address public fractalSigner = makeAddr("FractalSigner");

bytes32 public airgrabMerkleRoot = 0x945d83ced94efc822fed712b4c4694b4e1129607ec5bbd2ab971bb08dca4d809; // Mock root
Expand All @@ -43,7 +42,7 @@ contract GovernanceFactoryTest is TestSetup {
additionalAllocationAmounts: Arrays.uints(200)
});

factory.createGovernance(watchdogMultiSig, celoCommunityFund, airgrabMerkleRoot, fractalSigner, allocationParams);
factory.createGovernance(watchdogMultiSig, airgrabMerkleRoot, fractalSigner, allocationParams);
}

// ========================================
Expand Down Expand Up @@ -112,7 +111,7 @@ contract GovernanceFactoryTest is TestSetup {
});

vm.prank(owner);
factory.createGovernance(watchdogMultiSig, celoCommunityFund, airgrabMerkleRoot, fractalSigner, allocationParams);
factory.createGovernance(watchdogMultiSig, airgrabMerkleRoot, fractalSigner, allocationParams);

assertEq(factory.mentoToken().balanceOf(makeAddr("Recipient1")), (supply * 55) / 1000);
assertEq(factory.mentoToken().balanceOf(makeAddr("Recipient2")), (supply * 50) / 1000);
Expand Down
5 changes: 2 additions & 3 deletions test/governance/IntegrationTests/GovernanceIntegration.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ contract GovernanceIntegrationTest is TestSetup {
Locking public locking;

address public celoGovernance = makeAddr("CeloGovernance");
address public celoCommunityFund = makeAddr("CeloCommunityFund");
address public watchdogMultisig = makeAddr("WatchdogMultisig");

GnosisSafe public safeSingleton;
Expand Down Expand Up @@ -136,7 +135,7 @@ contract GovernanceIntegrationTest is TestSetup {
factory = new GovernanceFactory(celoGovernance);

vm.prank(celoGovernance);
factory.createGovernance(watchdogMultisig, celoCommunityFund, merkleRoot, fractalSigner, allocationParams);
factory.createGovernance(watchdogMultisig, merkleRoot, fractalSigner, allocationParams);
proxyAdmin = factory.proxyAdmin();
mentoToken = factory.mentoToken();
emission = factory.emission();
Expand Down Expand Up @@ -180,7 +179,7 @@ contract GovernanceIntegrationTest is TestSetup {
assertEq(airgrab.cliffPeriod(), 0);
assertEq(address(airgrab.token()), address(mentoToken));
assertEq(address(airgrab.locking()), address(locking));
assertEq(address(airgrab.celoCommunityFund()), address(celoCommunityFund));
assertEq(address(airgrab.mentoTreasury()), address(governanceTimelockAddress));

bytes32 proposerRole = governanceTimelock.PROPOSER_ROLE();
bytes32 executorRole = governanceTimelock.EXECUTOR_ROLE();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ contract FuzzLockingIntegrationTest is TestSetup {
Locking public locking;

address public celoGovernance = makeAddr("CeloGovernance");
address public celoCommunityFund = makeAddr("CeloCommunityFund");
address public watchdogMultisig = makeAddr("WatchdogMultisig");
address public mentoLabsMultisig = makeAddr("MentoLabsMultisig");
address public fractalSigner = makeAddr("FractalSigner");
Expand All @@ -50,7 +49,7 @@ contract FuzzLockingIntegrationTest is TestSetup {
});

vm.prank(celoGovernance);
factory.createGovernance(watchdogMultisig, celoCommunityFund, merkleRoot, fractalSigner, allocationParams);
factory.createGovernance(watchdogMultisig, merkleRoot, fractalSigner, allocationParams);
mentoToken = factory.mentoToken();
governanceTimelock = factory.governanceTimelock();
locking = factory.locking();
Expand Down

0 comments on commit b9c8ae1

Please sign in to comment.