-
-
Save beirao/2e79c9c4a72a02cfb5498cbb95c4e9ce to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function _repayLendingPool(address asset /*, uint256 amount*/) internal { | |
| DataTypes.MiniPoolReserveData storage reserve = _reserves[asset]; | |
| repayVars memory vars; | |
| vars.aTokenAddress = reserve.aTokenAddress; | |
| if (IAERC6909(reserve.aTokenAddress).isTranche(reserve.aTokenID)) { | |
| vars.underlyingAsset = IAToken(asset).UNDERLYING_ASSET_ADDRESS(); | |
| vars.underlyingDebt = | |
| IAToken(asset).convertToShares(getCurrentLendingPoolDebt(vars.underlyingAsset)); // share | |
| if (vars.underlyingDebt != 0) { | |
| // if (vars.underlyingDebt < amount) { | |
| uint256 amount = vars.underlyingDebt; | |
| // } | |
| MiniPoolWithdrawLogic.internalWithdraw( | |
| MiniPoolWithdrawLogic.withdrawParams( | |
| asset, amount, address(this), _reservesCount | |
| ), | |
| _reserves, | |
| _usersConfig, | |
| _reservesList, | |
| _addressesProvider | |
| ); // MUST use share | |
| IERC20 aToken = IERC20(ATokenNonRebasing(asset).ATOKEN_ADDRESS()); | |
| amount = aToken.balanceOf(address(this)); // asset | |
| aToken.approve(_addressesProvider.getLendingPool(), amount); | |
| ILendingPool(_addressesProvider.getLendingPool()).repayWithATokens( | |
| vars.underlyingAsset, true, amount, address(this) | |
| ); // MUST use asset | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment