Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PIP-26: Transition from MATIC to POL Validator Rewards #60

Merged
merged 1 commit into from
Jun 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/DefaultEmissionManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,12 @@ contract DefaultEmissionManager is Ownable2StepUpgradeable, IDefaultEmissionMana
emit TokenMint(amountToMint, msg.sender);

IPolygonEcosystemToken _token = token;

_token.mint(address(this), amountToMint);

_token.safeTransfer(treasury, treasuryAmt);
// backconvert POL to MATIC before sending to StakeManager
migration.unmigrateTo(stakeManager, stakeManagerAmt);

_token.safeTransfer(stakeManager, stakeManagerAmt);
Copy link

@web3security web3security Jun 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Despite this will solve potential issues while unmigrating during minting (if migration contract does not have enough MATIC) it will eventually create an issue with regard to rewards allocation at the StakeManager contract due to the transition period where both MATIC and POL will be allocated actually producing a situation where users might claim MATIC for their POL.

Here is a script that is being used to keep track of MATIC surplus along the way just to understand the different states that MATIC and POL will have in case that help: https://github.com/Polypheral/rewards-toolkit/blob/main/scripts/stakingDashboardV2.js#L24

}

/// @inheritdoc IDefaultEmissionManager
Expand Down
14 changes: 4 additions & 10 deletions test/DefaultEmissionManager.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ contract DefaultEmissionManagerTest is Test {
emissionManager.mint();
// timeElapsed is zero, so no minting
assertEq(polygon.balanceOf(stakeManager), 0);
assertEq(matic.balanceOf(stakeManager), 0);
assertEq(polygon.balanceOf(treasury), 0);
}

Expand All @@ -145,9 +144,7 @@ contract DefaultEmissionManagerTest is Test {
assertApproxEqAbs(newSupply, polygon.totalSupply(), _MAX_PRECISION_DELTA);
uint256 totalAmtMinted = polygon.totalSupply() - initialTotalSupply;
uint256 totalAmtMintedOneThird = totalAmtMinted / 3;
assertEq(matic.balanceOf(stakeManager), totalAmtMinted - totalAmtMintedOneThird);
assertEq(matic.balanceOf(treasury), 0);
assertEq(polygon.balanceOf(stakeManager), 0);
assertEq(polygon.balanceOf(stakeManager), totalAmtMinted - totalAmtMintedOneThird);
assertEq(polygon.balanceOf(treasury), totalAmtMintedOneThird);
}

Expand All @@ -166,8 +163,7 @@ contract DefaultEmissionManagerTest is Test {
assertApproxEqAbs(newSupply, polygon.totalSupply(), _MAX_PRECISION_DELTA);
uint256 balance = (polygon.totalSupply() - initialTotalSupply) / 3;
uint256 stakeManagerBalance = (polygon.totalSupply() - initialTotalSupply) - balance;
assertEq(matic.balanceOf(stakeManager), stakeManagerBalance);
assertEq(polygon.balanceOf(stakeManager), 0);
assertEq(polygon.balanceOf(stakeManager), stakeManagerBalance);
assertEq(polygon.balanceOf(treasury), balance);

initialTotalSupply = polygon.totalSupply(); // for the new run
Expand All @@ -185,8 +181,7 @@ contract DefaultEmissionManagerTest is Test {
balance += totalAmtMintedOneThird;
stakeManagerBalance += totalAmtMinted - totalAmtMintedOneThird;

assertEq(matic.balanceOf(stakeManager), stakeManagerBalance);
assertEq(polygon.balanceOf(stakeManager), 0);
assertEq(polygon.balanceOf(stakeManager), stakeManagerBalance);
assertEq(polygon.balanceOf(treasury), balance);
}

Expand All @@ -213,8 +208,7 @@ contract DefaultEmissionManagerTest is Test {
balance += totalAmtMintedOneThird;
stakeManagerBalance += totalAmtMinted - totalAmtMintedOneThird;

assertEq(matic.balanceOf(stakeManager), stakeManagerBalance);
assertEq(polygon.balanceOf(stakeManager), 0);
assertEq(polygon.balanceOf(stakeManager), stakeManagerBalance);
assertEq(polygon.balanceOf(treasury), balance);
}
}
Expand Down
Loading