Skip to content

Commit

Permalink
feat: check amounts in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
efecarranza committed Feb 21, 2025
1 parent 5da5eb4 commit 8e7107f
Showing 1 changed file with 32 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
pragma solidity ^0.8.0;

import {IERC20} from 'openzeppelin-contracts/contracts/token/ERC20/IERC20.sol';
import {IAaveOracle} from 'aave-address-book/AaveV2.sol';
import {AaveV3Ethereum, AaveV3EthereumAssets} from 'aave-address-book/AaveV3Ethereum.sol';
import {GovernanceV3Ethereum} from 'aave-address-book/GovernanceV3Ethereum.sol';
import {GhoEthereum} from 'aave-address-book/GhoEthereum.sol';
Expand Down Expand Up @@ -295,11 +296,39 @@ contract AaveV3Ethereum_GSMsMigrationToGSM4626_20250114_Test is ProtocolV3TestBa
IERC20(AaveV3EthereumAssets.GHO_UNDERLYING).approve(proposal.NEW_GSM_USDC(), 1_200 ether);
IERC20(AaveV3EthereumAssets.GHO_UNDERLYING).approve(proposal.NEW_GSM_USDT(), 1_200 ether);

IGsm(proposal.NEW_GSM_USDC()).sellAsset(1_000e6, address(this));
IGsm(proposal.NEW_GSM_USDT()).sellAsset(1_000e6, address(this));
uint256 amountUnderlying = 1_000e6;
uint256 balanceBeforeUsdcGsm = IERC20(AaveV3EthereumAssets.USDC_STATA_TOKEN).balanceOf(
proposal.NEW_GSM_USDC()
);
uint256 balanceBeforeUsdtGsm = IERC20(AaveV3EthereumAssets.USDT_STATA_TOKEN).balanceOf(
proposal.NEW_GSM_USDT()
);

IGsm(proposal.NEW_GSM_USDC()).sellAsset(amountUnderlying, address(this));
IGsm(proposal.NEW_GSM_USDT()).sellAsset(amountUnderlying, address(this));

assertEq(
IERC20(AaveV3EthereumAssets.USDC_STATA_TOKEN).balanceOf(proposal.NEW_GSM_USDC()),
balanceBeforeUsdcGsm + amountUnderlying,
'amounts USDC after sellAsset not equal'
);
assertEq(
IERC20(AaveV3EthereumAssets.USDT_STATA_TOKEN).balanceOf(proposal.NEW_GSM_USDT()),
balanceBeforeUsdtGsm + amountUnderlying,
'amounts USDT after sellAsset not equal'
);

IGsm(proposal.NEW_GSM_USDC()).buyAsset(500e6, address(this));
IGsm(proposal.NEW_GSM_USDT()).buyAsset(500e6, address(this));

assertEq(
IERC20(AaveV3EthereumAssets.USDC_STATA_TOKEN).balanceOf(proposal.NEW_GSM_USDC()),
balanceBeforeUsdcGsm + amountUnderlying - 500e6
);
assertEq(
IERC20(AaveV3EthereumAssets.USDT_STATA_TOKEN).balanceOf(proposal.NEW_GSM_USDT()),
balanceBeforeUsdtGsm + amountUnderlying - 500e6
);
}

function _checkRolesConfig(IGsm gsm) internal view {
Expand Down Expand Up @@ -335,7 +364,7 @@ contract AaveV3Ethereum_GSMsMigrationToGSM4626_20250114_Test is ProtocolV3TestBa
function _mockAssetPrice(address priceOracle, address asset, uint256 price) internal {
vm.mockCall(
priceOracle,
abi.encodeWithSelector(IPriceOracle.getAssetPrice.selector, asset),
abi.encodeWithSelector(IAaveOracle.getAssetPrice.selector, asset),
abi.encode(price)
);
}
Expand Down Expand Up @@ -400,10 +429,6 @@ interface IOracleSwapFreezer {
function performUpkeep(bytes calldata) external;
}

interface IPriceOracle {
function getAssetPrice(address asset) external view returns (uint256);
}

interface IFixedPriceStrategy4626 {
function getAssetPriceInGho(uint256 assetAmount, bool roundUp) external view returns (uint256);
function getGhoPriceInAsset(uint256 ghoAmount, bool roundUp) external view returns (uint256);
Expand Down

0 comments on commit 8e7107f

Please sign in to comment.