Skip to content

Commit ae9ad30

Browse files
update natspec
1 parent 8ed00b2 commit ae9ad30

File tree

1 file changed

+29
-7
lines changed

1 file changed

+29
-7
lines changed

src/EulerSwapPeriphery.sol

Lines changed: 29 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(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(eulerSwap, tokenIn, tokenOut, amountIn, amountOut);
3939
}
4040

4141
/// @inheritdoc IEulerSwapPeriphery
@@ -56,9 +56,13 @@ contract EulerSwapPeriphery is IEulerSwapPeriphery {
5656
return computeQuote(IEulerSwap(eulerSwap), tokenIn, tokenOut, amountOut, false);
5757
}
5858

59-
function _swap(address eulerSwap, address tokenIn, address tokenOut, uint256 amountIn, uint256 amountOut)
60-
internal
61-
{
59+
/// @dev Internal function to execute a token swap through EulerSwap
60+
/// @param eulerSwap The EulerSwap contract address to execute the swap through
61+
/// @param tokenIn The address of the input token being swapped
62+
/// @param tokenOut The address of the output token being received
63+
/// @param amountIn The amount of input tokens to swap
64+
/// @param amountOut The amount of output tokens to receive
65+
function swap(address eulerSwap, address tokenIn, address tokenOut, uint256 amountIn, uint256 amountOut) internal {
6266
IERC20(tokenIn).safeTransferFrom(msg.sender, eulerSwap, amountIn);
6367

6468
bool isAsset0In = tokenIn < tokenOut;
@@ -67,8 +71,18 @@ contract EulerSwapPeriphery is IEulerSwapPeriphery {
6771
: IEulerSwap(eulerSwap).swap(amountOut, 0, msg.sender, "");
6872
}
6973

70-
/// @dev High-level quoting function. It handles fees and performs
71-
/// state validation, for example that there is sufficient cash available.
74+
/// @dev Computes the quote for a swap by applying fees and validating state conditions
75+
/// @param eulerSwap The EulerSwap contract to quote from
76+
/// @param tokenIn The input token address
77+
/// @param tokenOut The output token address
78+
/// @param amount The amount to quote (input amount if exactIn=true, output amount if exactIn=false)
79+
/// @param exactIn True if quoting for exact input amount, false if quoting for exact output amount
80+
/// @return The quoted amount (output amount if exactIn=true, input amount if exactIn=false)
81+
/// @dev Validates:
82+
/// - EulerSwap operator is installed
83+
/// - Token pair is supported
84+
/// - Sufficient reserves exist
85+
/// - Sufficient cash is available
7286
function computeQuote(IEulerSwap eulerSwap, address tokenIn, address tokenOut, uint256 amount, bool exactIn)
7387
internal
7488
view
@@ -115,9 +129,17 @@ contract EulerSwapPeriphery is IEulerSwapPeriphery {
115129
return quote;
116130
}
117131

132+
/// @notice Binary searches for the output amount along a swap curve given input parameters
118133
/// @dev General-purpose routine for binary searching swapping curves.
119134
/// Although some curves may have more efficient closed-form solutions,
120135
/// this works with any monotonic curve.
136+
/// @param eulerSwap The EulerSwap contract to search the curve for
137+
/// @param reserve0 Current reserve of asset0 in the pool
138+
/// @param reserve1 Current reserve of asset1 in the pool
139+
/// @param amount The input or output amount depending on exactIn
140+
/// @param exactIn True if amount is input amount, false if amount is output amount
141+
/// @param asset0IsInput True if asset0 is being input, false if asset1 is being input
142+
/// @return output The calculated output amount from the binary search
121143
function binarySearch(
122144
IEulerSwap eulerSwap,
123145
uint112 reserve0,

0 commit comments

Comments
 (0)