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

Finding/uni 1993 exchangeratestored decimals are incorrect and misaligned #178

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
5 changes: 5 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@ ignore:
- "contracts/mocks/"
- "test/foundry/"
- "contracts/peripheral"
coverage:
status:
project:
default:
threshold: 1%
2 changes: 1 addition & 1 deletion contracts/market/UToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ contract UToken is IUToken, Controller, ERC20PermitUpgradeable, ReentrancyGuardU
}

function exchangeRateStored() public view returns (uint256) {
return decimalReducing(_exchangeRateStored(), underlyingDecimal);
return _exchangeRateStored();
}

/**
Expand Down
4 changes: 4 additions & 0 deletions test/foundry/uToken/TestMintRedeem.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ contract TestMintRedeem is TestUTokenBase {
erc20Mock.approve(address(uToken), mintAmount);
uToken.mint(mintAmount);
uint256 exchangeRateStored = uToken.exchangeRateStored();
if (tokenDecimals < 18) exchangeRateStored = exchangeRateStored / 10 ** (18 - tokenDecimals);
uint256 uBalance = uToken.balanceOf(ALICE);
uint256 ercBalance = erc20Mock.balanceOf(ALICE);
uint256 mintFee = (mintAmount * MINT_FEE_RATE) / 1e18;
Expand All @@ -83,6 +84,7 @@ contract TestMintRedeem is TestUTokenBase {
erc20Mock.approve(address(uToken), mintAmount);
uToken.mint(mintAmount);
uint256 exchangeRateStored = uToken.exchangeRateStored();
if (tokenDecimals < 18) exchangeRateStored = exchangeRateStored / 10 ** (18 - tokenDecimals);

uint256 mintFee = (mintAmount * MINT_FEE_RATE) / 1e18;
uint256 totalRedeemable = uToken.totalRedeemable();
Expand All @@ -105,6 +107,7 @@ contract TestMintRedeem is TestUTokenBase {
erc20Mock.approve(address(uToken), mintAmount);
uToken.mint(mintAmount);
uint256 exchangeRateStored = uToken.exchangeRateStored();
if (tokenDecimals < 18) exchangeRateStored = exchangeRateStored / 10 ** (18 - tokenDecimals);
uint256 mintFee = (mintAmount * MINT_FEE_RATE) / 1e18;

uint256 uBalance = uToken.balanceOf(ALICE);
Expand All @@ -129,6 +132,7 @@ contract TestMintRedeem is TestUTokenBase {
uint256 utokenBal = uToken.balanceOf(ALICE);

uint256 exchangeRateStored = uToken.exchangeRateStored();
if (tokenDecimals < 18) exchangeRateStored = exchangeRateStored / 10 ** (18 - tokenDecimals);
assertEq((utokenBal * exchangeRateStored) / 1e18, uToken.balanceOfUnderlying(ALICE));

uToken.borrow(ALICE, borrowAmount);
Expand Down
Loading