Skip to content

Commit

Permalink
added voting power to the migrate event
Browse files Browse the repository at this point in the history
  • Loading branch information
jordaniza committed Dec 27, 2024
1 parent 5162aa9 commit 9cdae2c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/escrow/increasing/VotingEscrowIncreasing_v1_1_0.sol
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ contract VotingEscrowV1_1_0 is
// check the migration contract is set and the tokenid is active
if (migrator == address(0)) revert MigrationNotActive();
if (!IERC721EMB(lockNFT).isApprovedOrOwner(_msgSender(), _tokenId)) revert NotOwner();
if (votingPower(_tokenId) == 0) revert CannotExit();

uint256 votingPowerSnapshot = votingPower(_tokenId);
if (votingPowerSnapshot == 0) revert CannotExit();

// the user should be approved
address owner = IERC721EMB(lockNFT).ownerOf(_tokenId);
Expand All @@ -143,7 +145,7 @@ contract VotingEscrowV1_1_0 is
newTokenId = VotingEscrowV1_1_0(migrator).migrateTo(value, owner);

// emit the migrated event
emit Migrated(owner, _tokenId, newTokenId, value);
emit Migrated(owner, _tokenId, newTokenId, value, votingPowerSnapshot);

return newTokenId;
}
Expand Down
4 changes: 3 additions & 1 deletion src/escrow/increasing/interfaces/IMigrateable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ interface IMigrateableEventsAndErrors {
/// @param oldTokenId TokenId burned in the old staking contract
/// @param newTokenId TokenId minted in the new staking contract
/// @param amount The locked amount migrated between contracts
/// @param votingPower The voting power at the time of migration
event Migrated(
address indexed owner,
uint256 indexed oldTokenId,
uint256 indexed newTokenId,
uint256 amount
uint256 amount,
uint256 votingPower
);
error MigrationAlreadySet();
error MigrationNotActive();
Expand Down
3 changes: 2 additions & 1 deletion test/escrow/migration/MigrationStateless.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,9 @@ contract TestMigrationStateless is MigrationBase {

vm.startPrank(depositor);
{
uint votingPower = src.escrow.votingPower(tokenId);
vm.expectEmit(true, true, true, true);
emit Migrated(depositor, tokenId, 1, 100 ether);
emit Migrated(depositor, tokenId, 1, 100 ether, votingPower);
newTokenId = src.escrow.migrateFrom(tokenId);
}
vm.stopPrank();
Expand Down

0 comments on commit 9cdae2c

Please sign in to comment.