Skip to content

Commit

Permalink
fix: return incase amountToMint == 0, rm unchecked block
Browse files Browse the repository at this point in the history
  • Loading branch information
DhairyaSethi committed Aug 31, 2023
1 parent 81ac66d commit 425c494
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
10 changes: 2 additions & 8 deletions src/DefaultInflationManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ contract DefaultInflationManager is
using SafeERC20 for IPolygon;

error InvalidAddress();
error NotEnoughMint();

// log2(2%pa continuously compounded inflation per second) in 18 decimals(Wad), see _inflatedSupplyAfter
uint256 public constant INTEREST_PER_SECOND_LOG2 = 0.000000000914951192e18;
Expand Down Expand Up @@ -76,13 +75,8 @@ contract DefaultInflationManager is
uint256 newSupply = _inflatedSupplyAfter(
block.timestamp - startTimestamp // time elapsed since deployment
);
uint256 amountToMint;
unchecked {
// currentSupply is always less than newSupply because POL token is strictly inflationary,
// _burn method is not exposed
amountToMint = newSupply - currentSupply;
}
if (amountToMint == 0) revert NotEnoughMint();
uint256 amountToMint = newSupply - currentSupply;
if (amountToMint == 0) return; // no minting required

uint256 treasuryAmt = amountToMint / 2;
uint256 stakeManagerAmt = amountToMint - treasuryAmt;
Expand Down
3 changes: 0 additions & 3 deletions test/DefaultInflationManager.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {Test} from "forge-std/Test.sol";

contract DefaultInflationManagerTest is Test {
error InvalidAddress();
error NotEnoughMint();

ERC20PresetMinterPauser public matic;
Polygon public polygon;
Expand Down Expand Up @@ -133,7 +132,6 @@ contract DefaultInflationManagerTest is Test {
}

function test_Mint() external {
vm.expectRevert(NotEnoughMint.selector);
inflationManager.mint();
// timeElapsed is zero, so no minting
assertEq(polygon.balanceOf(stakeManager), 0);
Expand All @@ -149,7 +147,6 @@ contract DefaultInflationManagerTest is Test {

skip(delay);

if (delay == 0) vm.expectRevert(NotEnoughMint.selector);
inflationManager.mint();

inputs[2] = vm.toString(elapsedTime);
Expand Down

0 comments on commit 425c494

Please sign in to comment.