Skip to content

Commit

Permalink
Fix bugs in DSCEngineTest.t.sol: errors in calculating liquidation bo…
Browse files Browse the repository at this point in the history
…nus amount
  • Loading branch information
0xEmiya committed Jan 3, 2025
1 parent 62d29e5 commit ef9acd2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions test/unit/DSCEngineTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ contract DSCEngineTest is StdCheats, Test {
function testLiquidationPayoutIsCorrect() public liquidated {
uint256 liquidatorWethBalance = ERC20Mock(weth).balanceOf(liquidator);
uint256 expectedWeth = dsce.getTokenAmountFromUsd(weth, amountToMint)
+ (dsce.getTokenAmountFromUsd(weth, amountToMint) / dsce.getLiquidationBonus());
+ (dsce.getTokenAmountFromUsd(weth, amountToMint) * dsce.getLiquidationBonus() / dsce.getLiquidationPrecision());
uint256 hardCodedExpected = 6_111_111_111_111_111_110;
assertEq(liquidatorWethBalance, hardCodedExpected);
assertEq(liquidatorWethBalance, expectedWeth);
Expand All @@ -462,7 +462,7 @@ contract DSCEngineTest is StdCheats, Test {
function testUserStillHasSomeEthAfterLiquidation() public liquidated {
// Get how much WETH the user lost
uint256 amountLiquidated = dsce.getTokenAmountFromUsd(weth, amountToMint)
+ (dsce.getTokenAmountFromUsd(weth, amountToMint) / dsce.getLiquidationBonus());
+ (dsce.getTokenAmountFromUsd(weth, amountToMint) * dsce.getLiquidationBonus() / dsce.getLiquidationPrecision());

uint256 usdAmountLiquidated = dsce.getUsdValue(weth, amountLiquidated);
uint256 expectedUserCollateralValueInUsd = dsce.getUsdValue(weth, amountCollateral) - (usdAmountLiquidated);
Expand Down

0 comments on commit ef9acd2

Please sign in to comment.