diff --git a/contracts/Migrator.sol b/contracts/Migrator.sol index c098717a..cf827c04 100644 --- a/contracts/Migrator.sol +++ b/contracts/Migrator.sol @@ -31,8 +31,6 @@ contract Migrator is Governable { event LockupsMigrated(address indexed user, uint256[] ogvLockupIds, uint256 newStakeAmount, uint256 newDuration); error MigrationAlreadyStarted(); - error MigrationIsInactive(); - error MigrationNotComplete(); error ContractInsolvent(uint256 expectedOGN, uint256 availableOGN); error LockupIdsRequired(); error InvalidStakeAmount(); @@ -79,45 +77,21 @@ contract Migrator is Governable { endTime = block.timestamp + 365 days; } - /** - * @notice Decommissions the contract. Can be called only - * after a year since `start()` was invoked. Burns - * all OGN in the contract by transferring them to - * to address(0xdead). - */ - function decommission() external { - // Only after a year of staking - if (endTime == 0 || isMigrationActive()) { - revert MigrationNotComplete(); - } - - emit Decommissioned(); - - uint256 ognBalance = ogn.balanceOf(address(this)); - if (ognBalance > 0) { - // OGN doesn't allow burning of tokens. Has `onlyOwner` - // modifier on `burn` and `burnFrom` methods. Also, - // `transfer` has a address(0) check. So, this transfers - // everything to address(0xdead). The `owner` multisig of - // OGN token can call `burnFrom(address(0xdead))` later. - - ogn.transfer(address(0xdead), ognBalance); - } - } - /** * @notice Computes the amount of OGN needed for migration * and if the contract has more OGN than that, it - * transfers it back to the treasury. + * transfers it back to the treasury. If migration complete, transfers all. * @param treasury Address that receives excess OGN */ - function transferExcessTokens(address treasury) external onlyGovernor isSolvent { + function transferExcessTokens(address treasury) external onlyGovernor { uint256 availableOGN = ogn.balanceOf(address(this)); - uint256 totalOGV = ogv.totalSupply() - ogv.balanceOf(address(this)); - uint256 maxOGNNeeded = (totalOGV * CONVERSION_RATE) / 1 ether; - if (availableOGN > maxOGNNeeded) { + if (endTime == 0 || isMigrationActive()) { + uint256 maxOGNNeeded = (ogv.totalSupply() * CONVERSION_RATE) / 1 ether; ogn.transfer(treasury, availableOGN - maxOGNNeeded); + } else { + emit Decommissioned(); + ogn.transfer(treasury, availableOGN); } } diff --git a/tests/staking/Migrator.t.sol b/tests/staking/Migrator.t.sol index e5156f21..203ca8b7 100644 --- a/tests/staking/Migrator.t.sol +++ b/tests/staking/Migrator.t.sol @@ -106,8 +106,8 @@ contract MigratorTest is Test { vm.stopPrank(); vm.warp(migrator.endTime() + 100); - - migrator.decommission(); + vm.prank(governor); + migrator.transferExcessTokens(address(0xdead)); assertEq(ogn.balanceOf(address(migrator)), 0 ether, "OGN leftover"); assertEq(ogn.balanceOf(address(0xdead)), maxOgnAmount - 0.09137 ether, "OGN not sent to burn address"); @@ -167,20 +167,6 @@ contract MigratorTest is Test { vm.stopPrank(); } - function testRevertDecommissionBeforeEnd() public { - vm.warp(migrator.endTime() - 1000); - - vm.expectRevert(bytes4(keccak256("MigrationNotComplete()"))); - migrator.decommission(); - } - - function testRevertDecommissionBeforeStart() public { - Migrator newMigrator = new Migrator(address(ogv), address(ogn), address(1), address(1)); - - vm.expectRevert(bytes4(keccak256("MigrationNotComplete()"))); - newMigrator.decommission(); - } - function testMigrateStakes() public { vm.startPrank(alice); ogvStaking.mockStake(10000 ether, 365 days);