Skip to content

Commit 56e7400

Browse files
optimize vault0() & vaulr1() calls
1 parent f49b4fe commit 56e7400

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/EulerSwapPeriphery.sol

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,10 @@ contract EulerSwapPeriphery is IEulerSwapPeriphery {
251251
function _getLimits(IEulerSwap es, bool asset0IsInput) internal view returns (uint256 inLimit, uint256 outLimit) {
252252
inLimit = outLimit = type(uint112).max;
253253
address eulerAccount = es.eulerAccount();
254+
(IEVault vault0, IEVault vault1) = (IEVault(es.vault0()), IEVault(es.vault1()));
254255
// Supply caps on input
255256
{
256-
IEVault vault = IEVault(asset0IsInput ? es.vault0() : es.vault1());
257+
IEVault vault = IEVault(asset0IsInput ? vault0 : vault1);
257258
uint256 maxDeposit = vault.debtOf(eulerAccount) + vault.maxDeposit(eulerAccount);
258259
if (maxDeposit < inLimit) inLimit = maxDeposit;
259260
}
@@ -267,7 +268,7 @@ contract EulerSwapPeriphery is IEulerSwapPeriphery {
267268

268269
// Remaining cash and borrow caps in output
269270
{
270-
IEVault vault = IEVault(asset0IsInput ? es.vault1() : es.vault0());
271+
IEVault vault = IEVault(asset0IsInput ? vault1 : vault0);
271272

272273
uint256 cash = vault.cash();
273274
if (cash < outLimit) outLimit = cash;

0 commit comments

Comments
 (0)