Skip to content

Commit

Permalink
fix: cleanup imports
Browse files Browse the repository at this point in the history
refactor: cleanup some things
(cherry picked from commit dd7166d0640e1a5bb9ad7afa03d9a21c6eb938ee)
  • Loading branch information
sakulstra committed Aug 16, 2024
1 parent 63dc7f2 commit 103f389
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 33 deletions.
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
2 changes: 1 addition & 1 deletion tests/periphery/static-a-token/ERC20AaveLMUpgradable.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down
54 changes: 27 additions & 27 deletions tests/periphery/static-a-token/ERC4626StataTokenUpgradeable.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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)),
Expand All @@ -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);

Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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);

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -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 ###
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down
3 changes: 0 additions & 3 deletions tests/periphery/static-a-token/TestBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion tests/utils/DiffUtils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 103f389

Please sign in to comment.