Skip to content

Commit b2112f4

Browse files
committed
use OZ's mulDiv instead of Uniswap's
1 parent d11e168 commit b2112f4

File tree

4 files changed

+2
-8
lines changed

4 files changed

+2
-8
lines changed

.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,3 @@
1010
[submodule "lib/ethereum-vault-connector"]
1111
path = lib/ethereum-vault-connector
1212
url = https://github.com/euler-xyz/ethereum-vault-connector
13-
[submodule "lib/v4-core"]
14-
path = lib/v4-core
15-
url = https://github.com/Uniswap/v4-core

lib/v4-core

Lines changed: 0 additions & 1 deletion
This file was deleted.

remappings.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@ evk/=lib/euler-vault-kit/src/
44
ethereum-vault-connector/=lib/ethereum-vault-connector/src/
55
evk-test/=lib/euler-vault-kit/test/
66
permit2/=lib/euler-vault-kit/lib/permit2/
7-
@uniswap/v4-core/=lib/v4-core/src/

src/EulerSwapPeriphery.sol

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {IEVault} from "evk/EVault/IEVault.sol";
66
import {IEulerSwapPeriphery} from "./interfaces/IEulerSwapPeriphery.sol";
77
import {IERC20, IEulerSwap, SafeERC20} from "./EulerSwap.sol";
88
import {Math} from "openzeppelin-contracts/utils/math/Math.sol";
9-
import "@uniswap/v4-core/libraries/FullMath.sol";
109

1110
contract EulerSwapPeriphery is IEulerSwapPeriphery {
1211
using SafeERC20 for IERC20;
@@ -195,7 +194,7 @@ contract EulerSwapPeriphery is IEulerSwapPeriphery {
195194
* @notice Computes the inverse of the `f()` function for the EulerSwap liquidity curve.
196195
* @dev Solves for `x` given `y` using the quadratic formula derived from the liquidity curve:
197196
* x = (-b + sqrt(b^2 + 4ac)) / 2a
198-
* Utilises Uniswap's FullMath to avoid overflow and ensures precision with upward rounding.
197+
* Utilises mulDiv to avoid overflow and ensures precision with upward rounding.
199198
*
200199
* @param y The y-coordinate input value (must be greater than `y0`).
201200
* @param px Price factor for the x-axis (scaled by 1e18, between 1e18 and 1e36).
@@ -223,7 +222,7 @@ contract EulerSwapPeriphery is IEulerSwapPeriphery {
223222

224223
// B^2 component, using FullMath for overflow safety
225224
uint256 absB = B < 0 ? uint256(-B) : uint256(B);
226-
uint256 squaredB = FullMath.mulDiv(absB, absB, 1e18) + (absB * absB % 1e18 == 0 ? 0 : 1);
225+
uint256 squaredB = Math.mulDiv(absB, absB, 1e18, Math.Rounding.Ceil);
227226

228227
// 4 * A * C component of the quadratic formula
229228
uint256 AC4 = Math.mulDiv(

0 commit comments

Comments
 (0)