Skip to content

Commit

Permalink
adds decimals() override
Browse files Browse the repository at this point in the history
  • Loading branch information
WalidOfNow committed Jun 27, 2024
1 parent de6833d commit 6ea6fad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 6 additions & 2 deletions mainnet-contracts/src/PufToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ contract PufToken is IPufStakingPool, ERC20, ERC20Permit {
/**
* @notice The underlying token decimals
*/
uint256 internal immutable _TOKEN_DECIMALS;
uint8 internal immutable _TOKEN_DECIMALS;

/**
* @notice Puffer Token factory
Expand All @@ -54,7 +54,7 @@ contract PufToken is IPufStakingPool, ERC20, ERC20Permit {
// The Factory is the deployer of the contract
PUFFER_FACTORY = PufferL2Depositor(msg.sender);
TOKEN = ERC20(token);
_TOKEN_DECIMALS = uint256(TOKEN.decimals());
_TOKEN_DECIMALS = TOKEN.decimals();
totalDepositCap = depositCap;
}

Expand Down Expand Up @@ -214,4 +214,8 @@ contract PufToken is IPufStakingPool, ERC20, ERC20Permit {

IMigrator(migratorContract).migrate({ depositor: depositor, destination: destination, amount: amount });
}

function decimals() public view override returns (uint8 _decimals) {
return _TOKEN_DECIMALS;
}
}
2 changes: 2 additions & 0 deletions mainnet-contracts/test/unit/PufferL2Staking.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ contract PufferL2Staking is UnitTestHelper {
pufToken.withdraw(bob, amount);

assertEq(sixDecimal.balanceOf(bob), amount, "bob got same amount");
assertEq(sixDecimal.decimals(), 6, "decimals matches orginal token");

Check failure on line 183 in mainnet-contracts/test/unit/PufferL2Staking.t.sol

View workflow job for this annotation

GitHub Actions / unit-tests

orginal ==> original
}

// Deposit & withdraw 22 decimal token
Expand Down Expand Up @@ -209,6 +210,7 @@ contract PufferL2Staking is UnitTestHelper {
pufToken.withdraw(bob, amount);

assertEq(twentyTwoDecimal.balanceOf(bob), amount, "bob got same amount");
assertEq(twentyTwoDecimal.decimals(), 22, "decimals matches orginal token");

Check failure on line 213 in mainnet-contracts/test/unit/PufferL2Staking.t.sol

View workflow job for this annotation

GitHub Actions / unit-tests

orginal ==> original
}

// Good Permit signature signature
Expand Down

0 comments on commit 6ea6fad

Please sign in to comment.