Skip to content

Commit 6d35d87

Browse files
committed
pass interfaces instead of raw addresses to internal functions
spearbit #13
1 parent e3c7a40 commit 6d35d87

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/EulerSwapPeriphery.sol

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ contract EulerSwapPeriphery is IEulerSwapPeriphery {
2424

2525
require(amountOut >= amountOutMin, AmountOutLessThanMin());
2626

27-
swap(eulerSwap, tokenIn, tokenOut, amountIn, amountOut);
27+
swap(IEulerSwap(eulerSwap), tokenIn, tokenOut, amountIn, amountOut);
2828
}
2929

3030
/// @inheritdoc IEulerSwapPeriphery
@@ -35,7 +35,7 @@ contract EulerSwapPeriphery is IEulerSwapPeriphery {
3535

3636
require(amountIn <= amountInMax, AmountInMoreThanMax());
3737

38-
swap(eulerSwap, tokenIn, tokenOut, amountIn, amountOut);
38+
swap(IEulerSwap(eulerSwap), tokenIn, tokenOut, amountIn, amountOut);
3939
}
4040

4141
/// @inheritdoc IEulerSwapPeriphery
@@ -73,13 +73,13 @@ contract EulerSwapPeriphery is IEulerSwapPeriphery {
7373
/// @param tokenOut The address of the output token being received
7474
/// @param amountIn The amount of input tokens to swap
7575
/// @param amountOut The amount of output tokens to receive
76-
function swap(address eulerSwap, address tokenIn, address tokenOut, uint256 amountIn, uint256 amountOut) internal {
77-
IERC20(tokenIn).safeTransferFrom(msg.sender, eulerSwap, amountIn);
76+
function swap(IEulerSwap eulerSwap, address tokenIn, address tokenOut, uint256 amountIn, uint256 amountOut)
77+
internal
78+
{
79+
IERC20(tokenIn).safeTransferFrom(msg.sender, address(eulerSwap), amountIn);
7880

7981
bool isAsset0In = tokenIn < tokenOut;
80-
(isAsset0In)
81-
? IEulerSwap(eulerSwap).swap(0, amountOut, msg.sender, "")
82-
: IEulerSwap(eulerSwap).swap(amountOut, 0, msg.sender, "");
82+
(isAsset0In) ? eulerSwap.swap(0, amountOut, msg.sender, "") : eulerSwap.swap(amountOut, 0, msg.sender, "");
8383
}
8484

8585
/// @dev Computes the quote for a swap by applying fees and validating state conditions

0 commit comments

Comments
 (0)