diff --git a/foundry.toml b/foundry.toml index f9eff6ea..4bde07e1 100644 --- a/foundry.toml +++ b/foundry.toml @@ -4,7 +4,7 @@ sizes = true libs = ["node_modules", "lib"] fs_permissions = [{ access = "read", path = "./config/" }] gas_limit = "18446744073709551615" -evm_version = "shanghai" +evm_version = "cancun" optimizer = true optimizer_runs = 200 diff --git a/test/integration/TestIntegrationBorrow.sol b/test/integration/TestIntegrationBorrow.sol index 3a41014d..9636abf9 100644 --- a/test/integration/TestIntegrationBorrow.sol +++ b/test/integration/TestIntegrationBorrow.sol @@ -46,7 +46,7 @@ contract TestIntegrationBorrow is IntegrationTest { assertApproxEqDust(morpho.borrowBalance(market.underlying, onBehalf), amount, "borrow != amount"); // Assert Morpho's position on pool. - assertApproxEqAbs(market.variableBorrowOf(address(morpho)), amount, 2, "morphoVariableBorrow != amount"); + assertApproxEqAbs(market.variableBorrowOf(address(morpho)), amount, 3, "morphoVariableBorrow != amount"); // Assert receiver's underlying balance. assertEq( @@ -97,7 +97,7 @@ contract TestIntegrationBorrow is IntegrationTest { ); // Assert Morpho's position on pool. - assertApproxEqAbs(market.variableBorrowOf(address(morpho)), 0, 2, "morphoVariableBorrow != 0"); + assertApproxEqAbs(market.variableBorrowOf(address(morpho)), 0, 3, "morphoVariableBorrow != 0"); // Assert receiver's underlying balance. assertEq( diff --git a/test/integration/TestIntegrationMorphoGetters.sol b/test/integration/TestIntegrationMorphoGetters.sol index a80d700f..fa751077 100644 --- a/test/integration/TestIntegrationMorphoGetters.sol +++ b/test/integration/TestIntegrationMorphoGetters.sol @@ -100,4 +100,11 @@ contract TestIntegrationMorphoGetters is IntegrationTest { uint256 premiumToProtocol = pool.FLASHLOAN_PREMIUM_TOTAL(); assertEq(premiumToProtocol, premiumTotal, "all premium goes to protocol"); } + + function testPoolRevision() public view { + (bool success, bytes memory data) = address(pool).staticcall(abi.encodeWithSignature("POOL_REVISION()", hex"")); + uint256 fetchedRevision = abi.decode(data, (uint256)); + assertTrue(success, "pool revision failed"); + assertEq(fetchedRevision, 9, "wrong revision"); + } } diff --git a/test/integration/TestIntegrationPoolLib.sol b/test/integration/TestIntegrationPoolLib.sol index 4cf182fc..616e670e 100644 --- a/test/integration/TestIntegrationPoolLib.sol +++ b/test/integration/TestIntegrationPoolLib.sol @@ -38,7 +38,7 @@ contract TestIntegrationPoolLibSupply is TestIntegrationPoolLib { pool.supplyToPool(dai, amount, pool.getReserveNormalizedIncome(dai)); assertEq(ERC20(dai).balanceOf(address(this)) + amount, balanceBefore, "balance"); - assertApproxEqAbs(ERC20(aDai).balanceOf(address(this)), aBalanceBefore + amount, 1, "aBalance"); + assertApproxEqAbs(ERC20(aDai).balanceOf(address(this)), aBalanceBefore + amount, 2, "aBalance"); } } @@ -59,7 +59,7 @@ contract TestIntegrationPoolLibBorrow is TestIntegrationPoolLib { pool.borrowFromPool(dai, amount / 2); assertEq(ERC20(dai).balanceOf(address(this)), balanceBefore + amount / 2, "balance"); - assertApproxEqAbs(ERC20(vDai).balanceOf(address(this)), vBalanceBefore + amount / 2, 1, "vBalance"); + assertApproxEqAbs(ERC20(vDai).balanceOf(address(this)), vBalanceBefore + amount / 2, 2, "vBalance"); } } @@ -83,7 +83,7 @@ contract TestIntegrationPoolLibRepay is TestIntegrationPoolLib { pool.repayToPool(dai, vDai, amount / 4); assertEq(ERC20(dai).balanceOf(address(this)) + amount / 4, balanceBefore, "balance"); - assertApproxEqAbs(ERC20(vDai).balanceOf(address(this)) + amount / 4, vBalanceBefore, 1, "vBalance"); + assertApproxEqAbs(ERC20(vDai).balanceOf(address(this)) + amount / 4, vBalanceBefore, 2, "vBalance"); } } diff --git a/test/integration/TestIntegrationRepay.sol b/test/integration/TestIntegrationRepay.sol index 295af66a..c4e8854e 100644 --- a/test/integration/TestIntegrationRepay.sol +++ b/test/integration/TestIntegrationRepay.sol @@ -71,7 +71,7 @@ contract TestIntegrationRepay is IntegrationTest { assertApproxEqAbs( market.supplyOf(address(morpho)), test.morphoSupplyBefore, 2, "morphoSupply != morphoSupplyBefore" ); - assertApproxEqAbs(market.variableBorrowOf(address(morpho)), 0, 1, "morphoVariableBorrow != 0"); + assertApproxEqAbs(market.variableBorrowOf(address(morpho)), 0, 3, "morphoVariableBorrow != 0"); // Assert user's underlying balance. assertApproxEqAbs( @@ -154,7 +154,7 @@ contract TestIntegrationRepay is IntegrationTest { 3, "morphoSupply != morphoSupplyBefore + promoted" ); - assertApproxEqAbs(market.variableBorrowOf(address(morpho)), 0, 2, "morphoVariableBorrow != 0"); + assertApproxEqAbs(market.variableBorrowOf(address(morpho)), 0, 3, "morphoVariableBorrow != 0"); // Assert user's underlying balance. assertApproxLeAbs( @@ -238,7 +238,7 @@ contract TestIntegrationRepay is IntegrationTest { 1, "morphoSupply != morphoSupplyBefore + supplyGapBefore" ); - assertApproxEqAbs(market.variableBorrowOf(address(morpho)), 0, 1, "morphoVariableBorrow != 0"); + assertApproxEqAbs(market.variableBorrowOf(address(morpho)), 0, 2, "morphoVariableBorrow != 0"); assertApproxEqDust(_supplyGap(market), 0, "supplyGapAfter != 0"); // Assert user's underlying balance. @@ -325,7 +325,7 @@ contract TestIntegrationRepay is IntegrationTest { assertApproxEqAbs( morphoSupply, test.morphoSupplyBefore + test.borrowed, 2, "morphoSupply != morphoSupplyBefore + borrowed" ); - assertApproxEqAbs(market.variableBorrowOf(address(morpho)), 0, 1, "morphoVariableBorrow != 0"); + assertApproxEqAbs(market.variableBorrowOf(address(morpho)), 0, 2, "morphoVariableBorrow != 0"); // Assert user's underlying balance. assertApproxEqAbs( diff --git a/test/integration/TestIntegrationSupply.sol b/test/integration/TestIntegrationSupply.sol index 41178b3b..8d8742c1 100644 --- a/test/integration/TestIntegrationSupply.sol +++ b/test/integration/TestIntegrationSupply.sol @@ -52,7 +52,7 @@ contract TestIntegrationSupply is IntegrationTest { assertApproxEqAbs( market.supplyOf(address(morpho)), test.morphoSupplyBefore + amount, - 1, + 2, "morphoSupply != morphoSupplyBefore + amount" ); @@ -105,7 +105,7 @@ contract TestIntegrationSupply is IntegrationTest { assertApproxGeAbs( market.supplyOf(address(morpho)), test.morphoSupplyBefore, 3, "morphoSupplyAfter != morphoSupplyBefore" ); - assertApproxEqAbs(market.variableBorrowOf(address(morpho)), 0, 1, "morphoVariableBorrow != 0"); + assertApproxEqAbs(market.variableBorrowOf(address(morpho)), 0, 4, "morphoVariableBorrow != 0"); // Assert user's underlying balance. assertApproxEqAbs( @@ -212,7 +212,7 @@ contract TestIntegrationSupply is IntegrationTest { test = _assertSupplyPool(market, amount, onBehalf, test); - assertApproxEqAbs(market.variableBorrowOf(address(morpho)), amount, 1, "morphoVariableBorrow != amount"); + assertApproxEqAbs(market.variableBorrowOf(address(morpho)), amount, 2, "morphoVariableBorrow != amount"); _assertMarketAccountingZero(test.morphoMarket); } diff --git a/test/integration/TestIntegrationWithdraw.sol b/test/integration/TestIntegrationWithdraw.sol index 0b0aa435..7e21bdde 100644 --- a/test/integration/TestIntegrationWithdraw.sol +++ b/test/integration/TestIntegrationWithdraw.sol @@ -74,7 +74,7 @@ contract TestIntegrationWithdraw is IntegrationTest { assertApproxEqAbs( market.supplyOf(address(morpho)), test.morphoSupplyBefore, 2, "morphoSupply != morphoSupplyBefore" ); - assertApproxEqAbs(market.variableBorrowOf(address(morpho)), 0, 2, "morphoVariableBorrow != 0"); + assertApproxEqAbs(market.variableBorrowOf(address(morpho)), 0, 3, "morphoVariableBorrow != 0"); // Assert receiver's underlying balance. assertApproxEqAbs( @@ -263,7 +263,7 @@ contract TestIntegrationWithdraw is IntegrationTest { assertApproxEqAbs( market.supplyOf(address(morpho)), test.morphoSupplyBefore, 1, "morphoSupply != morphoSupplyBefore" ); - assertApproxGeAbs(market.variableBorrowOf(address(morpho)), 0, 3, "morphoVariableBorrow != 0"); + assertApproxGeAbs(market.variableBorrowOf(address(morpho)), 0, 4, "morphoVariableBorrow != 0"); // Assert user's underlying balance. assertApproxLeAbs( @@ -363,7 +363,7 @@ contract TestIntegrationWithdraw is IntegrationTest { assertApproxEqAbs( market.supplyOf(address(morpho)), test.morphoSupplyBefore, 1, "morphoSupply != morphoSupplyBefore" ); - assertApproxEqAbs(morphoVariableBorrow, test.supplied, 2, "morphoVariableBorrow != supplied"); + assertApproxEqAbs(morphoVariableBorrow, test.supplied, 4, "morphoVariableBorrow != supplied"); // Assert user's underlying balance. assertApproxLeAbs( @@ -379,7 +379,7 @@ contract TestIntegrationWithdraw is IntegrationTest { assertApproxEqAbs( test.morphoMarket.deltas.borrow.scaledDelta.rayMul(test.indexes.borrow.poolIndex), morphoVariableBorrow, - 2, + 4, "borrowDelta != morphoVariableBorrow" ); assertApproxEqAbs( diff --git a/test/internal/TestInternalMorphoInternal.sol b/test/internal/TestInternalMorphoInternal.sol index 8abf8812..e27d8be0 100644 --- a/test/internal/TestInternalMorphoInternal.sol +++ b/test/internal/TestInternalMorphoInternal.sol @@ -156,12 +156,12 @@ contract TestInternalMorphoInternal is InternalTest { this.increaseP2PDeltasTest(underlying, amount); assertApproxEqAbs( - aTokenBalanceBefore + expectedAmount, ERC20(market.aToken).balanceOf(address(this)), 1, "aToken balance" + aTokenBalanceBefore + expectedAmount, ERC20(market.aToken).balanceOf(address(this)), 2, "aToken balance" ); assertApproxEqAbs( variableDebtTokenBalanceBefore + expectedAmount, ERC20(market.variableDebtToken).balanceOf(address(this)), - 1, + 2, "variable debt token balance" ); assertEq(deltas.supply.scaledDelta, newExpectedSupplyDelta, "supply delta");