Skip to content

Commit 5e0227b

Browse files
committed
fix: Reset allowance after Aave interaction
1 parent cca2c04 commit 5e0227b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

contracts/adapters/paraswap/ParaSwapRepayAdapter.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,15 @@ contract ParaSwapRepayAdapter is BaseParaSwapBuyAdapter, ReentrancyGuard {
127127

128128
//deposit collateral back in the pool, if left after the swap(buy)
129129
if (collateralBalanceLeft > 0) {
130-
IERC20(collateralAsset).safeApprove(address(POOL), 0);
131130
IERC20(collateralAsset).safeApprove(address(POOL), collateralBalanceLeft);
132131
POOL.deposit(address(collateralAsset), collateralBalanceLeft, msg.sender, 0);
132+
IERC20(collateralAsset).safeApprove(address(POOL), 0);
133133
}
134134

135135
// Repay debt. Approves 0 first to comply with tokens that implement the anti frontrunning approval fix
136-
IERC20(debtAsset).safeApprove(address(POOL), 0);
137136
IERC20(debtAsset).safeApprove(address(POOL), debtRepayAmount);
138137
POOL.repay(address(debtAsset), debtRepayAmount, debtRateMode, msg.sender);
138+
IERC20(debtAsset).safeApprove(address(POOL), 0);
139139

140140
{
141141
//transfer excess of debtAsset back to the user, if any
@@ -188,9 +188,9 @@ contract ParaSwapRepayAdapter is BaseParaSwapBuyAdapter, ReentrancyGuard {
188188
);
189189

190190
// Repay debt. Approves for 0 first to comply with tokens that implement the anti frontrunning approval fix.
191-
IERC20(debtAsset).safeApprove(address(POOL), 0);
192191
IERC20(debtAsset).safeApprove(address(POOL), debtRepayAmount);
193192
POOL.repay(address(debtAsset), debtRepayAmount, rateMode, initiator);
193+
IERC20(debtAsset).safeApprove(address(POOL), 0);
194194

195195
uint256 neededForFlashLoanRepay = amountSold.add(premium);
196196

0 commit comments

Comments
 (0)