@@ -71,16 +71,10 @@ contract ParaSwapRepayAdapter is BaseParaSwapBuyAdapter, ReentrancyGuard {
7171 uint256 collateralAmount = amounts[0 ];
7272 uint256 premium = premiums[0 ];
7373 address initiatorLocal = initiator;
74-
74+
7575 IERC20Detailed collateralAsset = IERC20Detailed (assets[0 ]);
76-
77- _swapAndRepay (
78- params,
79- premium,
80- initiatorLocal,
81- collateralAsset,
82- collateralAmount
83- );
76+
77+ _swapAndRepay (params, premium, initiatorLocal, collateralAsset, collateralAmount);
8478
8579 return true ;
8680 }
@@ -110,7 +104,6 @@ contract ParaSwapRepayAdapter is BaseParaSwapBuyAdapter, ReentrancyGuard {
110104 bytes calldata paraswapData ,
111105 PermitSignature calldata permitSignature
112106 ) external nonReentrant {
113-
114107 debtRepayAmount = getDebtRepayAmount (
115108 debtAsset,
116109 debtRateMode,
@@ -162,7 +155,6 @@ contract ParaSwapRepayAdapter is BaseParaSwapBuyAdapter, ReentrancyGuard {
162155 IERC20Detailed collateralAsset ,
163156 uint256 collateralAmount
164157 ) private {
165-
166158 (
167159 IERC20Detailed debtAsset ,
168160 uint256 debtRepayAmount ,
@@ -180,15 +172,19 @@ contract ParaSwapRepayAdapter is BaseParaSwapBuyAdapter, ReentrancyGuard {
180172 initiator
181173 );
182174
183- uint256 amountSold =
184- _buyOnParaSwap (
185- buyAllBalanceOffset,
186- paraswapData,
187- collateralAsset,
188- debtAsset,
189- collateralAmount,
190- debtRepayAmount
191- );
175+ uint256 amountSold = debtRepayAmount;
176+
177+ if (collateralAsset != debtAsset) {
178+ uint256 amountSold =
179+ _buyOnParaSwap (
180+ buyAllBalanceOffset,
181+ paraswapData,
182+ collateralAsset,
183+ debtAsset,
184+ collateralAmount,
185+ debtRepayAmount
186+ );
187+ }
192188
193189 // Repay debt. Approves for 0 first to comply with tokens that implement the anti frontrunning approval fix.
194190 IERC20 (debtAsset).safeApprove (address (LENDING_POOL), 0 );
0 commit comments