Skip to content

Commit bb2a007

Browse files
optimize isAccountOperatorAuthorized() call
1 parent 1461604 commit bb2a007

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/EulerSwapPeriphery.sol

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -239,32 +239,33 @@ contract EulerSwapPeriphery is IEulerSwapPeriphery {
239239
view
240240
returns (uint256 inLimit, uint256 outLimit)
241241
{
242+
if (
243+
!IEVC(IEulerSwap(eulerSwap).EVC()).isAccountOperatorAuthorized(
244+
IEulerSwap(eulerSwap).eulerAccount(), eulerSwap
245+
)
246+
) return (0, 0);
247+
242248
return _getLimits(IEulerSwap(eulerSwap), checkTokens(IEulerSwap(eulerSwap), tokenIn, tokenOut));
243249
}
244250

245251
function _getLimits(IEulerSwap es, bool asset0IsInput) internal view returns (uint256 inLimit, uint256 outLimit) {
246-
if (!IEVC(es.EVC()).isAccountOperatorAuthorized(es.eulerAccount(), address(es))) return (0, 0);
247-
248252
inLimit = outLimit = type(uint112).max;
249253

250254
// Supply caps on input
251-
252255
{
253256
IEVault vault = IEVault(asset0IsInput ? es.vault0() : es.vault1());
254257
uint256 maxDeposit = vault.debtOf(es.eulerAccount()) + vault.maxDeposit(es.eulerAccount());
255258
if (maxDeposit < inLimit) inLimit = maxDeposit;
256259
}
257260

258261
// Remaining reserves of output
259-
260262
{
261263
(uint112 reserve0, uint112 reserve1,) = es.getReserves();
262264
uint112 reserveLimit = asset0IsInput ? reserve1 : reserve0;
263265
if (reserveLimit < outLimit) outLimit = reserveLimit;
264266
}
265267

266268
// Remaining cash and borrow caps in output
267-
268269
{
269270
IEVault vault = IEVault(asset0IsInput ? es.vault1() : es.vault0());
270271

0 commit comments

Comments
 (0)