Skip to content

Commit

Permalink
fix 154
Browse files Browse the repository at this point in the history
  • Loading branch information
LayneHaber committed Jun 26, 2022
1 parent bc241f8 commit f981975
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,8 @@ contract NomadFacet is BaseConnextFacet {

// Edge case with some tokens: Example USDT in ETH Mainnet, after the backUnbacked call there could be a remaining allowance if not the whole amount is pulled by aave.
// Later, if we try to increase the allowance it will fail. USDT demands if allowance is not 0, it has to be set to 0 first.
// TODO: Should we call approve(0) and approve(totalRepayAmount) instead? or with a try catch to not affect gas on all cases?
// Example: https://github.com/aave/aave-v3-periphery/blob/ca184e5278bcbc10d28c3dbbc604041d7cfac50b/contracts/adapters/paraswap/ParaSwapRepayAdapter.sol#L138-L140
SafeERC20.safeApprove(IERC20(adopted), s.aavePool, 0);
SafeERC20.safeIncreaseAllowance(IERC20(adopted), s.aavePool, totalRepayAmount);

(bool success, ) = s.aavePool.call(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@ library AssetLogic {
success = true;

// perform the swap
// Edge case with some tokens: Example USDT in ETH Mainnet, after the backUnbacked call there could be a remaining allowance if not the whole amount is pulled by aave.
// Later, if we try to increase the allowance it will fail. USDT demands if allowance is not 0, it has to be set to 0 first.
// Example: https://github.com/aave/aave-v3-periphery/blob/ca184e5278bcbc10d28c3dbbc604041d7cfac50b/contracts/adapters/paraswap/ParaSwapRepayAdapter.sol#L138-L140
SafeERC20.safeApprove(IERC20(_assetIn), address(pool), 0);
SafeERC20.safeApprove(IERC20(_assetIn), address(pool), _amountIn);
amountIn = pool.swapExactOut(_amountOut, _assetIn, _assetOut, _maxIn);
}
Expand Down

0 comments on commit f981975

Please sign in to comment.