@@ -5,6 +5,7 @@ import {IEVC} from "evc/interfaces/IEthereumVaultConnector.sol";
5
5
import {IEVault, IERC20 , IBorrowing, IERC4626 , IRiskManager} from "evk/EVault/IEVault.sol " ;
6
6
import {IUniswapV2Callee} from "./interfaces/IUniswapV2Callee.sol " ;
7
7
import {IEulerSwap} from "./interfaces/IEulerSwap.sol " ;
8
+ import {IAllowanceTransfer} from "permit2/src/interfaces/IAllowanceTransfer.sol " ;
8
9
import {EVCUtil} from "evc/utils/EVCUtil.sol " ;
9
10
10
11
contract EulerSwap is IEulerSwap , EVCUtil {
@@ -164,8 +165,21 @@ contract EulerSwap is IEulerSwap, EVCUtil {
164
165
require (status != 2 , Locked ());
165
166
status = 1 ;
166
167
167
- IERC20 (asset0).approve (vault0, type (uint256 ).max);
168
- IERC20 (asset1).approve (vault1, type (uint256 ).max);
168
+ address permit2 = IEVault (vault0).permit2Address ();
169
+ if (permit2 == address (0 )) {
170
+ IERC20 (asset0).approve (vault0, type (uint256 ).max);
171
+ } else {
172
+ IERC20 (asset0).approve (permit2, type (uint256 ).max);
173
+ IAllowanceTransfer (permit2).approve (asset0, vault0, type (uint160 ).max, type (uint48 ).max);
174
+ }
175
+
176
+ permit2 = IEVault (vault1).permit2Address ();
177
+ if (permit2 == address (0 )) {
178
+ IERC20 (asset1).approve (vault1, type (uint256 ).max);
179
+ } else {
180
+ IERC20 (asset1).approve (permit2, type (uint256 ).max);
181
+ IAllowanceTransfer (permit2).approve (asset1, vault1, type (uint160 ).max, type (uint48 ).max);
182
+ }
169
183
170
184
IEVC (evc).enableCollateral (myAccount, vault0);
171
185
IEVC (evc).enableCollateral (myAccount, vault1);
0 commit comments