From 103f389dd8bd4dbc5b5c836476ff1d4e05dd75fb Mon Sep 17 00:00:00 2001 From: sakulstra Date: Fri, 16 Aug 2024 14:57:55 +0200 Subject: [PATCH] fix: cleanup imports refactor: cleanup some things (cherry picked from commit dd7166d0640e1a5bb9ad7afa03d9a21c6eb938ee) --- bun.lockb | Bin 91091 -> 91091 bytes package.json | 2 +- .../ERC20AaveLMUpgradable.t.sol | 2 +- .../ERC4626StataTokenUpgradeable.t.sol | 54 +++++++++--------- tests/periphery/static-a-token/TestBase.sol | 3 - tests/utils/DiffUtils.sol | 2 +- 6 files changed, 30 insertions(+), 33 deletions(-) diff --git a/bun.lockb b/bun.lockb index 471ed8580a4fd2c7f70ff7b2a474769a9baa45ce..dc28b8a63a9f4935f9a9bae4b3d26e5321092820 100755 GIT binary patch delta 143 zcmV;A0C4})#|6{J1&}Tv&#bB3ts(8f4Tf(bdu+Q9hF()-jk`I;WOCEzzEF*Eu}&Hg zlcW+Tlh6+cvzQQNOF-lap9yl83rk~8eVJyO9jPfQamJ>bDKLcpI{0A)Pm^@b%A(Gz x|G;$pqL%n_)?+QqLcayXDmPqqZrbR;DZsNmT)&+GG_(ErLn8q+w?Q2Nl141lL;L^$ delta 143 zcmV;A0C4})#|6{J1&}Tv6W$`<@azjz`v#X&jL<9fu1{GhU#Ycwpq>q#X)b#+u}&Hg zlOz`?lh6+cvzQQNOF;R4+^k0z)N|c#FTG_!baQ0M(ttgLyB=T_jQ)rX(}VhkIuXp^ xhHsUx+ETP`7px<1j#)4VBW>E7-#WeKVm-4xT)&+GGPC{pLn8q)w?Q2Nl18|?LBIe2 diff --git a/package.json b/package.json index c151c49a..e2047c8f 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "prettier-plugin-solidity": "^1.1.1" }, "dependencies": { - "@bgd-labs/aave-cli": "^0.16.2", + "@bgd-labs/aave-cli": "^0.16.4", "catapulta-verify": "^1.1.1" } } diff --git a/tests/periphery/static-a-token/ERC20AaveLMUpgradable.t.sol b/tests/periphery/static-a-token/ERC20AaveLMUpgradable.t.sol index 762c3229..d01a1172 100644 --- a/tests/periphery/static-a-token/ERC20AaveLMUpgradable.t.sol +++ b/tests/periphery/static-a-token/ERC20AaveLMUpgradable.t.sol @@ -85,7 +85,7 @@ contract ERC20AaveLMUpgradableTest is TestnetProcedures { contracts.emissionManager.setEmissionAdmin(rewardToken, emissionAdmin); } - function test_2701() external view { + function test_2701() external pure { assertEq( keccak256(abi.encode(uint256(keccak256('aave-dao.storage.ERC20AaveLM')) - 1)) & ~bytes32(uint256(0xff)), diff --git a/tests/periphery/static-a-token/ERC4626StataTokenUpgradeable.t.sol b/tests/periphery/static-a-token/ERC4626StataTokenUpgradeable.t.sol index e3977a2c..9d83e42e 100644 --- a/tests/periphery/static-a-token/ERC4626StataTokenUpgradeable.t.sol +++ b/tests/periphery/static-a-token/ERC4626StataTokenUpgradeable.t.sol @@ -7,10 +7,6 @@ import {IERC20Permit} from 'openzeppelin-contracts/contracts/token/ERC20/extensi import {IPool} from '../../../src/core/contracts/interfaces/IPool.sol'; import {TestnetProcedures, TestnetERC20} from '../../utils/TestnetProcedures.sol'; import {ERC4626Upgradeable, ERC4626StataTokenUpgradeable, IERC4626StataToken} from '../../../src/periphery/contracts/static-a-token/ERC4626StataTokenUpgradeable.sol'; -import {IRewardsController} from '../../../src/periphery/contracts/rewards/interfaces/IRewardsController.sol'; -import {PullRewardsTransferStrategy, ITransferStrategyBase} from '../../../src/periphery/contracts/rewards/transfer-strategies/PullRewardsTransferStrategy.sol'; -import {RewardsDataTypes} from '../../../src/periphery/contracts/rewards/libraries/RewardsDataTypes.sol'; -import {IEACAggregatorProxy} from '../../../src/periphery/contracts/misc/interfaces/IEACAggregatorProxy.sol'; import {DataTypes} from '../../../src/core/contracts/protocol/libraries/configuration/ReserveConfiguration.sol'; import {SigUtils} from '../../utils/SigUtils.sol'; @@ -46,7 +42,7 @@ contract ERC4626StataTokenUpgradeableTest is TestnetProcedures { erc4626Upgradeable.mockInit(address(reserveData.aTokenAddress)); } - function test_2701() external view { + function test_2701() external pure { assertEq( keccak256(abi.encode(uint256(keccak256('aave-dao.storage.ERC4626StataToken')) - 1)) & ~bytes32(uint256(0xff)), @@ -66,7 +62,7 @@ contract ERC4626StataTokenUpgradeableTest is TestnetProcedures { // ### DEPOSIT TESTS ### function test_depositATokens(uint128 assets, address receiver) public { - vm.assume(receiver != address(0)); + _validateReceiver(receiver); TestEnv memory env = _setupTestEnv(assets); _fundAToken(env.amount, user); @@ -106,7 +102,7 @@ contract ERC4626StataTokenUpgradeableTest is TestnetProcedures { uint128 assets, address receiver ) external { - vm.assume(receiver != address(0)); + _validateReceiver(receiver); TestEnv memory env = _setupTestEnv(assets); _fundUnderlying(env.amount, user); IERC4626StataToken.SignatureParams memory sig; @@ -130,7 +126,7 @@ contract ERC4626StataTokenUpgradeableTest is TestnetProcedures { uint128 assets, address receiver ) external { - vm.assume(receiver != address(0)); + _validateReceiver(receiver); TestEnv memory env = _setupTestEnv(assets); _fundAToken(env.amount, user); IERC4626StataToken.SignatureParams memory sig; @@ -151,7 +147,7 @@ contract ERC4626StataTokenUpgradeableTest is TestnetProcedures { } function test_depositWithPermit_underlying(uint128 assets, address receiver) external { - vm.assume(receiver != address(0)); + _validateReceiver(receiver); TestEnv memory env = _setupTestEnv(assets); _fundUnderlying(env.amount, user); @@ -220,7 +216,7 @@ contract ERC4626StataTokenUpgradeableTest is TestnetProcedures { // ### REDEEM TESTS ### function test_redeemATokens(uint256 assets, address receiver) public { - vm.assume(receiver != address(0)); + _validateReceiver(receiver); TestEnv memory env = _setupTestEnv(assets); uint256 shares = _fund4626(env.amount, user); @@ -266,7 +262,7 @@ contract ERC4626StataTokenUpgradeableTest is TestnetProcedures { } function test_redeem(uint256 assets, address receiver) external { - vm.assume(receiver != address(0)); + _validateReceiver(receiver); TestEnv memory env = _setupTestEnv(assets); uint256 shares = _fund4626(env.amount, user); @@ -278,7 +274,7 @@ contract ERC4626StataTokenUpgradeableTest is TestnetProcedures { // ### withdraw TESTS ### function test_withdraw(uint256 assets, address receiver) public { - vm.assume(receiver != address(0)); + _validateReceiver(receiver); TestEnv memory env = _setupTestEnv(assets); uint256 shares = _fund4626(env.amount, user); @@ -291,7 +287,7 @@ contract ERC4626StataTokenUpgradeableTest is TestnetProcedures { } function test_withdraw_shouldRevert_moreThenAvailable(uint256 assets, address receiver) public { - vm.assume(receiver != address(0)); + _validateReceiver(receiver); TestEnv memory env = _setupTestEnv(assets); _fund4626(env.amount, user); @@ -309,7 +305,7 @@ contract ERC4626StataTokenUpgradeableTest is TestnetProcedures { // ### mint TESTS ### function test_mint(uint256 assets, address receiver) public { - vm.assume(receiver != address(0)); + _validateReceiver(receiver); TestEnv memory env = _setupTestEnv(assets); _fundUnderlying(env.amount, user); @@ -331,7 +327,7 @@ contract ERC4626StataTokenUpgradeableTest is TestnetProcedures { uint256 shares = erc4626Upgradeable.previewDeposit(env.amount); vm.expectRevert(); - uint256 assetsUsedForMinting = erc4626Upgradeable.mint(shares + 1, receiver); + erc4626Upgradeable.mint(shares + 1, receiver); } // ### maxDeposit TESTS ### @@ -400,7 +396,7 @@ contract ERC4626StataTokenUpgradeableTest is TestnetProcedures { function test_maxRedeem_inSufficientAvailableLiquidity(uint256 amountToBorrow) public { uint128 assets = 1e8; amountToBorrow = bound(amountToBorrow, 1, assets); - uint256 shares = _fund4626(assets, user); + _fund4626(assets, user); // borrow out some assets address borrowUser = address(99); @@ -448,29 +444,33 @@ contract ERC4626StataTokenUpgradeableTest is TestnetProcedures { uint256 amount; } - function _setupTestEnv(uint256 amount) internal returns (TestEnv memory) { + function _validateReceiver(address receiver) internal view { + vm.assume(receiver != address(0) && receiver != address(aToken)); + } + + function _setupTestEnv(uint256 amount) internal pure returns (TestEnv memory) { TestEnv memory env; env.amount = bound(amount, 1, type(uint96).max); return env; } - function _fundUnderlying(uint256 assets, address user) internal { - deal(underlying, user, assets); + function _fundUnderlying(uint256 assets, address receiver) internal { + deal(underlying, receiver, assets); } - function _fundAToken(uint256 assets, address user) internal { - _fundUnderlying(assets, user); - vm.startPrank(user); + function _fundAToken(uint256 assets, address receiver) internal { + _fundUnderlying(assets, receiver); + vm.startPrank(receiver); IERC20(underlying).approve(address(contracts.poolProxy), assets); - contracts.poolProxy.deposit(underlying, assets, user, 0); + contracts.poolProxy.deposit(underlying, assets, receiver, 0); vm.stopPrank(); } - function _fund4626(uint256 assets, address user) internal returns (uint256) { - _fundAToken(assets, user); - vm.startPrank(user); + function _fund4626(uint256 assets, address receiver) internal returns (uint256) { + _fundAToken(assets, receiver); + vm.startPrank(receiver); IERC20(aToken).approve(address(erc4626Upgradeable), assets); - uint256 shares = erc4626Upgradeable.depositATokens(assets, user); + uint256 shares = erc4626Upgradeable.depositATokens(assets, receiver); vm.stopPrank(); return shares; } diff --git a/tests/periphery/static-a-token/TestBase.sol b/tests/periphery/static-a-token/TestBase.sol index 4a098285..51bfce1a 100644 --- a/tests/periphery/static-a-token/TestBase.sol +++ b/tests/periphery/static-a-token/TestBase.sol @@ -11,9 +11,6 @@ import {TestnetProcedures, TestnetERC20} from '../../utils/TestnetProcedures.sol import {DataTypes} from '../../../src/core/contracts/protocol/libraries/configuration/ReserveConfiguration.sol'; abstract contract BaseTest is TestnetProcedures { - bytes32 internal constant PERMIT_TYPEHASH = - keccak256('Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)'); - address constant OWNER = address(1234); address public constant EMISSION_ADMIN = address(25); diff --git a/tests/utils/DiffUtils.sol b/tests/utils/DiffUtils.sol index a5e7577d..23008fb5 100644 --- a/tests/utils/DiffUtils.sol +++ b/tests/utils/DiffUtils.sol @@ -22,7 +22,7 @@ contract DiffUtils is Test { string[] memory inputs = new string[](7); inputs[0] = 'npx'; - inputs[1] = '@bgd-labs/aave-cli@^0.16.2'; + inputs[1] = '@bgd-labs/aave-cli@^0.16.4'; inputs[2] = 'diff-snapshots'; inputs[3] = beforePath; inputs[4] = afterPath;