From 752b106cca9a87a26a0c883a7e7d0fc62f83f35a Mon Sep 17 00:00:00 2001 From: twygod Date: Thu, 25 Jul 2024 12:28:38 +0800 Subject: [PATCH 1/3] fix: exchangeRateStored decimals are incorrect and misaligned with exchangeRateCurrent --- contracts/market/UToken.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/market/UToken.sol b/contracts/market/UToken.sol index a582f304..9dc50ddc 100644 --- a/contracts/market/UToken.sol +++ b/contracts/market/UToken.sol @@ -548,7 +548,7 @@ contract UToken is IUToken, Controller, ERC20PermitUpgradeable, ReentrancyGuardU } function exchangeRateStored() public view returns (uint256) { - return decimalReducing(_exchangeRateStored(), underlyingDecimal); + return _exchangeRateStored(); } /** From f16ae2b25ab07f593af4df7ae6e105b1781a9c55 Mon Sep 17 00:00:00 2001 From: twygod Date: Thu, 25 Jul 2024 13:57:05 +0800 Subject: [PATCH 2/3] chg: update test --- test/foundry/uToken/TestMintRedeem.t.sol | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/foundry/uToken/TestMintRedeem.t.sol b/test/foundry/uToken/TestMintRedeem.t.sol index af1024f1..4bbcafb3 100644 --- a/test/foundry/uToken/TestMintRedeem.t.sol +++ b/test/foundry/uToken/TestMintRedeem.t.sol @@ -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; @@ -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(); @@ -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); @@ -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); From 42da00916c233c424c83d36b1b31825c2d6affe3 Mon Sep 17 00:00:00 2001 From: twygod Date: Fri, 26 Jul 2024 17:24:31 +0800 Subject: [PATCH 3/3] chg: modify coverage configuration (cherry picked from commit 7c119a0148a12841dc9e8c7cd627c51d2362e491) --- codecov.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/codecov.yml b/codecov.yml index 413c66b6..6e293bce 100644 --- a/codecov.yml +++ b/codecov.yml @@ -2,3 +2,8 @@ ignore: - "contracts/mocks/" - "test/foundry/" - "contracts/peripheral" +coverage: + status: + project: + default: + threshold: 1%