Skip to content

Commit

Permalink
add a check to make sure user can repay loans even with borrow disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
hexonaut committed Mar 12, 2024
1 parent a25614b commit 6828fcd
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions test/KillSwitchOracleIntegration.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { IPool } from "lib/aave-v3-core/contracts/interfaces/IPoo
import { IPoolConfigurator } from "lib/aave-v3-core/contracts/interfaces/IPoolConfigurator.sol";
import { ReserveConfiguration } from "lib/aave-v3-core/contracts/protocol/libraries/configuration/ReserveConfiguration.sol";
import { DataTypes } from "lib/aave-v3-core/contracts/protocol/libraries/types/DataTypes.sol";
import { IERC20 } from "lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";

import { KillSwitchOracle } from "src/KillSwitchOracle.sol";

Expand Down Expand Up @@ -38,6 +39,9 @@ contract KillSwitchOracleIntegrationTest is Test {
address constant RETH = 0xae78736Cd615f374D3085123A210448E74Fc6393;
address constant USDT = 0xdAC17F958D2ee523a2206206994597C13D831ec7;

address constant DAI_VAR_DEBT = 0xf705d2B7e92B3F38e6ae7afaDAA2fEE110fE5914;
address constant DAI_BORROWER_WALLET = 0xf8dE75c7B95edB6f1E639751318f117663021Cf0;

IPool pool = IPool(POOL);
IPoolConfigurator poolConfigurator = IPoolConfigurator(POOL_CONFIGURATOR);
IACLManager aclManager = IACLManager(ACL_MANAGER);
Expand Down Expand Up @@ -113,13 +117,22 @@ contract KillSwitchOracleIntegrationTest is Test {
assertEq(_getBorrowEnabled(GNO), false);
assertEq(_getBorrowEnabled(RETH), false);
assertEq(_getBorrowEnabled(USDT), false);

// Make sure users can still repay loans
uint256 userBalance = 40_187_695.578838876771725671e18;
deal(DAI, DAI_BORROWER_WALLET, 1e18);
assertEq(IERC20(DAI_VAR_DEBT).balanceOf(DAI_BORROWER_WALLET), userBalance);

vm.startPrank(DAI_BORROWER_WALLET);
IERC20(DAI).approve(address(pool), 1e18);
pool.repay(DAI, 1e18, 2, DAI_BORROWER_WALLET);
vm.stopPrank();

assertEq(IERC20(DAI_VAR_DEBT).balanceOf(DAI_BORROWER_WALLET), userBalance - 1e18);
}

function _getBorrowEnabled(address asset) internal view returns (bool) {
return pool.getConfiguration(asset).getBorrowingEnabled();
}

// TODO add some more specific checks to make sure existing users can top up collateral, repay loans and withdraw collateral.
// Also demonstate that users can't be liquidate or anything weird.

}

0 comments on commit 6828fcd

Please sign in to comment.