Submitted by cloudjunky
When repaying the AAVE Portal in repayAavePortal() the _local asset is used to repay the loan in _backLoan() rather than the adopted asset. This is likely to cause issues in production when actually repaying loans if the asset/token being repayed to AAVE is not the same as the asset/token that was borrowed.
The comment on L93 of PortalFacet.sol states;
The swap is executed on L98 in the call to AssetLogic.swapFromLocalAssetIfNeededForExactOut() however the return value adopted is never used (its an unused local variable). The full function is shown below;
The balance of the _local token is reduced but instead of the adopted token being passed to _backLoan() in L112 the _local token is used.
Vim
To be consistent with the comments in the repayAavePortal() function adopted should be passed to _backLoan so that the loan is repayed in the appropriate token.
Remove the reference to _local in the _backLoan() function and replace it with adopted so it reads;
_backLoan(adopted, _backingAmount, _feeAmount, _transferId);
jakekidd (Connext) confirmed and resolved
0xleastwood (judge) commented:
