diff --git a/packages/contracts/test/amo/AaveAMO.t.sol b/packages/contracts/test/amo/AaveAMO.t.sol index 320fe76dd..e680c29a3 100644 --- a/packages/contracts/test/amo/AaveAMO.t.sol +++ b/packages/contracts/test/amo/AaveAMO.t.sol @@ -92,25 +92,35 @@ contract AaveAMOTest is DiamondTestSetup { aaveAMO.aaveDepositCollateral(address(collateralToken), depositAmount); // Check if the deposit was successful - assertEq(aToken.balanceOf(address(aaveAMO)), depositAmount); + assertApproxEqAbs( + aToken.balanceOf(address(aaveAMO)), + depositAmount, + 1e2 + ); // little error this is due to interest rate assertEq(collateralToken.balanceOf(address(aaveAMO)), 0); } function testAaveWithdrawCollateral_ShouldWithdrawSuccessfully() public { - uint256 withdrawAmount = 1000e18; + uint256 depositAmount = 1000e18; // Mints collateral to AMO vm.prank(collateralOwner); - collateralToken.mint(address(aaveAMO), withdrawAmount); + collateralToken.mint(address(aaveAMO), depositAmount); // Owner deposits collateral to Aave Pool vm.prank(owner); - aaveAMO.aaveDepositCollateral(address(collateralToken), withdrawAmount); + aaveAMO.aaveDepositCollateral(address(collateralToken), depositAmount); // Check balances before withdrawal - assertEq(aToken.balanceOf(address(aaveAMO)), withdrawAmount); + assertApproxEqAbs( + aToken.balanceOf(address(aaveAMO)), + depositAmount, + 1e2 + ); // little error this is due to interest rate assertEq(collateralToken.balanceOf(address(aaveAMO)), 0); + uint256 withdrawAmount = aToken.balanceOf(address(aaveAMO)); + // Owner withdraws collateral from Aave Pool vm.prank(owner); aaveAMO.aaveWithdrawCollateral( @@ -134,8 +144,12 @@ contract AaveAMOTest is DiamondTestSetup { vm.prank(owner); aaveAMO.aaveDepositCollateral(address(collateralToken), depositAmount); - // Check balances before withdrawal - assertEq(aToken.balanceOf(address(aaveAMO)), depositAmount); + // Check balances before borrow + assertApproxEqAbs( + aToken.balanceOf(address(aaveAMO)), + depositAmount, + 1e2 + ); // little error this is due to interest rate assertEq(collateralToken.balanceOf(address(aaveAMO)), 0); uint256 borrowAmount = 1e18; @@ -150,7 +164,6 @@ contract AaveAMOTest is DiamondTestSetup { // Check if the borrow was successful assertEq(collateralToken.balanceOf(address(aaveAMO)), borrowAmount); - assertEq(vToken.scaledBalanceOf(address(aaveAMO)), borrowAmount); } function testAaveRepay_ShouldRepayAssetSuccessfully() public { @@ -164,8 +177,12 @@ contract AaveAMOTest is DiamondTestSetup { vm.prank(owner); aaveAMO.aaveDepositCollateral(address(collateralToken), depositAmount); - // Check balances before withdrawal - assertEq(aToken.balanceOf(address(aaveAMO)), depositAmount); + // Check balances before borrow + assertApproxEqAbs( + aToken.balanceOf(address(aaveAMO)), + depositAmount, + 1e2 + ); // little error this is due to interest rate assertEq(collateralToken.balanceOf(address(aaveAMO)), 0); uint256 borrowAmount = 1e18; @@ -180,7 +197,6 @@ contract AaveAMOTest is DiamondTestSetup { // Check if the borrow was successful assertEq(collateralToken.balanceOf(address(aaveAMO)), borrowAmount); - assertEq(vToken.scaledBalanceOf(address(aaveAMO)), borrowAmount); // Owner repays asset to Aave Pool vm.prank(owner);