Skip to content

Commit

Permalink
Low 20 and Low 21
Browse files Browse the repository at this point in the history
  • Loading branch information
merisman committed Oct 20, 2024
1 parent b061363 commit 1bae663
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
14 changes: 12 additions & 2 deletions src/BaseAllocation.sol
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ abstract contract BaseAllocation is ReentrancyGuard, SafeTransferLib{
uint48 shortStopTime
);
event MetaVesT_TransferabilityUpdated(address indexed grantee, bool isTransferable);
event MetaVest_TransferRightsPending(address indexed grantee, address indexed pendingGrantee);
event MetaVesT_TransferredRights(address indexed grantee, address transferee);
event MetaVesT_UnlockRateUpdated(address indexed grantee, uint208 unlockRate);
event MetaVesT_VestingRateUpdated(address indexed grantee, uint208 vestingRate);
Expand All @@ -156,6 +157,7 @@ abstract contract BaseAllocation is ReentrancyGuard, SafeTransferLib{
enum GovType {all, vested, unlocked}

address public grantee; // grantee of the tokens
address public pendingGrantee; // address of the pending grantee
bool transferable; // whether grantee can transfer their MetaVesT in whole
Milestone[] public milestones; // array of Milestone structs
Allocation public allocation; // struct containing vesting and unlocking details
Expand Down Expand Up @@ -286,8 +288,16 @@ abstract contract BaseAllocation is ReentrancyGuard, SafeTransferLib{
function transferRights(address _newOwner) external onlyGrantee {
if(_newOwner == address(0)) revert MetaVesT_ZeroAddress();
if(!transferable) revert MetaVesT_VestNotTransferable();
emit MetaVesT_TransferredRights(grantee, _newOwner);
grantee = _newOwner;
emit MetaVest_TransferRightsPending(grantee, _newOwner);
pendingGrantee = _newOwner;
}

/// @notice confirms the transfer of the rights of the VestingAllocation to a new owner
function confirmTransfer() external {
if(msg.sender != pendingGrantee) revert MetaVesT_OnlyGrantee();
grantee = pendingGrantee;
emit MetaVesT_TransferredRights(grantee, pendingGrantee);
pendingGrantee = address(0);
}

/// @notice withdraws tokens from the VestingAllocation
Expand Down
6 changes: 0 additions & 6 deletions src/MetaVesTController.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ contract metavestController is SafeTransferLib {
uint256 internal constant AMENDMENT_TIME_LIMIT = 604800;
uint256 internal constant ARRAY_LENGTH_LIMIT = 20;

mapping(address => address[]) public vestingAllocations;
mapping(address => address[]) public restrictedTokenAllocations;
mapping(address => address[]) public tokenOptionAllocations;
mapping(bytes32 => EnumerableSet.AddressSet) private sets;
EnumerableSet.Bytes32Set private setNames;

Expand Down Expand Up @@ -343,7 +340,6 @@ contract metavestController is SafeTransferLib {
);
safeTransferFrom(_allocation.tokenContract, authority, vestingAllocation, _total);

vestingAllocations[_grantee].push(vestingAllocation);
return vestingAllocation;
}

Expand All @@ -367,7 +363,6 @@ contract metavestController is SafeTransferLib {
);

safeTransferFrom(_allocation.tokenContract, authority, tokenOptionAllocation, _total);
tokenOptionAllocations[_grantee].push(tokenOptionAllocation);
return tokenOptionAllocation;
}

Expand All @@ -390,7 +385,6 @@ contract metavestController is SafeTransferLib {
);

safeTransferFrom(_allocation.tokenContract, authority, restrictedTokenAward, _total);
restrictedTokenAllocations[_grantee].push(restrictedTokenAward);
return restrictedTokenAward;
}

Expand Down
10 changes: 6 additions & 4 deletions test/controller.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1165,7 +1165,7 @@ contract MetaVestControllerTest is Test {
);

assertEq(token.balanceOf(vestingAllocation), 1100e18);
assertEq(controller.vestingAllocations(grantee, 0), vestingAllocation);
// assertEq(controller.vestingAllocations(grantee, 0), vestingAllocation);
}

function testCreateTokenOptionAllocation() public {
Expand Down Expand Up @@ -1202,7 +1202,7 @@ contract MetaVestControllerTest is Test {
);

assertEq(token.balanceOf(tokenOptionAllocation), 1100e18);
assertEq(controller.tokenOptionAllocations(grantee, 0), tokenOptionAllocation);
//assertEq(controller.tokenOptionAllocations(grantee, 0), tokenOptionAllocation);
}

function testCreateRestrictedTokenAward() public {
Expand Down Expand Up @@ -1240,7 +1240,7 @@ contract MetaVestControllerTest is Test {
);

assertEq(token.balanceOf(restrictedTokenAward), 1100e18);
assertEq(controller.restrictedTokenAllocations(grantee, 0), restrictedTokenAward);
//assertEq(controller.restrictedTokenAllocations(grantee, 0), restrictedTokenAward);
}

function testUpdateTransferability() public {
Expand All @@ -1258,7 +1258,9 @@ contract MetaVestControllerTest is Test {
controller.updateMetavestTransferability(vestingAllocation, true);
vm.prank(grantee);
RestrictedTokenAward(vestingAllocation).transferRights(transferee);
uint256 newTimestamp = startTimestamp + 100; // 101
vm.prank(transferee);
RestrictedTokenAward(vestingAllocation).confirmTransfer();
uint256 newTimestamp = startTimestamp + 100; // 101
vm.warp(newTimestamp);
skip(10);
vm.prank(transferee);
Expand Down

0 comments on commit 1bae663

Please sign in to comment.