Skip to content

Commit 2bd922b

Browse files
chore: rename to EulerSwap
1 parent 4f031d4 commit 2bd922b

10 files changed

+170
-284
lines changed

TODO

Lines changed: 0 additions & 40 deletions
This file was deleted.

src/Maglev.sol renamed to src/EulerSwap.sol

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// SPDX-License-Identifier: UNLICENSED
22
pragma solidity ^0.8.27;
33

4-
import {EVCUtil} from "evc/utils/EVCUtil.sol";
54
import {IEVC} from "evc/interfaces/IEthereumVaultConnector.sol";
65
import {IEVault, IERC20, IBorrowing, IERC4626, IRiskManager} from "evk/EVault/IEVault.sol";
76
import {IUniswapV2Callee} from "./interfaces/IUniswapV2Callee.sol";
8-
import {IMaglev} from "./interfaces/IMaglev.sol";
7+
import {IEulerSwap} from "./interfaces/IEulerSwap.sol";
8+
import {EVCUtil} from "evc/utils/EVCUtil.sol";
99

10-
contract Maglev is IMaglev, EVCUtil {
10+
contract EulerSwap is IEulerSwap, EVCUtil {
1111
bytes32 public constant curve = keccak256("EulerSwap v1");
1212

1313
address public immutable vault0;
@@ -37,7 +37,7 @@ contract Maglev is IMaglev, EVCUtil {
3737
error AssetsOutOfOrderOrEqual();
3838
error CurveViolation();
3939

40-
event MaglevCreated(address indexed maglev, address indexed asset0, address indexed asset1);
40+
event EulerSwapCreated(address indexed eulerSwap, address indexed asset0, address indexed asset1);
4141

4242
event Swap(
4343
address indexed sender,
@@ -76,7 +76,7 @@ contract Maglev is IMaglev, EVCUtil {
7676
}
7777

7878
constructor(Params memory params, CurveParams memory curveParams) EVCUtil(params.evc) {
79-
// Maglev params
79+
// EulerSwap params
8080

8181
require(params.fee < 1e18, BadFee());
8282

@@ -106,10 +106,10 @@ contract Maglev is IMaglev, EVCUtil {
106106
concentrationX = curveParams.concentrationX;
107107
concentrationY = curveParams.concentrationY;
108108

109-
emit MaglevCreated(address(this), asset0Addr, asset1Addr);
109+
emit EulerSwapCreated(address(this), asset0Addr, asset1Addr);
110110
}
111111

112-
/// @inheritdoc IMaglev
112+
/// @inheritdoc IEulerSwap
113113
function activate() public {
114114
require(status != 2, Locked());
115115
status = 1;
@@ -126,7 +126,7 @@ contract Maglev is IMaglev, EVCUtil {
126126
return y0 + px * 1e18 / py * (c * (2 * x0 - xt) / 1e18 + (1e18 - c) * x0 / 1e18 * x0 / xt - x0) / 1e18;
127127
}
128128

129-
/// @inheritdoc IMaglev
129+
/// @inheritdoc IEulerSwap
130130
function verify(uint256 newReserve0, uint256 newReserve1) public view returns (bool) {
131131
if (newReserve0 >= initialReserve0) {
132132
if (newReserve1 >= initialReserve1) return true;
@@ -137,7 +137,7 @@ contract Maglev is IMaglev, EVCUtil {
137137
}
138138
}
139139

140-
/// @inheritdoc IMaglev
140+
/// @inheritdoc IEulerSwap
141141
function swap(uint256 amount0Out, uint256 amount1Out, address to, bytes calldata data)
142142
external
143143
callThroughEVC

src/MaglevPeriphery.sol renamed to src/EulerSwapPeriphery.sol

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ pragma solidity ^0.8.27;
33

44
import {IEVC} from "evc/interfaces/IEthereumVaultConnector.sol";
55
import {IEVault} from "evk/EVault/IEVault.sol";
6-
import {IMaglev} from "./interfaces/IMaglev.sol";
7-
import {IMaglevPeriphery} from "./interfaces/IMaglevPeriphery.sol";
6+
import {IEulerSwap} from "./interfaces/IEulerSwap.sol";
7+
import {IEulerSwapPeriphery} from "./interfaces/IEulerSwapPeriphery.sol";
88

9-
contract MaglevPeriphery is IMaglevPeriphery {
9+
contract EulerSwapPeriphery is IEulerSwapPeriphery {
1010
address private immutable evc;
1111

1212
constructor(address evc_) {
@@ -18,52 +18,54 @@ contract MaglevPeriphery is IMaglevPeriphery {
1818
error InsufficientReserves();
1919
error InsufficientCash();
2020

21-
/// @inheritdoc IMaglevPeriphery
22-
function quoteExactInput(address maglev, address tokenIn, address tokenOut, uint256 amountIn)
21+
/// @inheritdoc IEulerSwapPeriphery
22+
function quoteExactInput(address eulerSwap, address tokenIn, address tokenOut, uint256 amountIn)
2323
external
2424
view
2525
returns (uint256)
2626
{
27-
return computeQuote(IMaglev(maglev), tokenIn, tokenOut, amountIn, true);
27+
return computeQuote(IEulerSwap(eulerSwap), tokenIn, tokenOut, amountIn, true);
2828
}
2929

30-
/// @inheritdoc IMaglevPeriphery
31-
function quoteExactOutput(address maglev, address tokenIn, address tokenOut, uint256 amountOut)
30+
/// @inheritdoc IEulerSwapPeriphery
31+
function quoteExactOutput(address eulerSwap, address tokenIn, address tokenOut, uint256 amountOut)
3232
external
3333
view
3434
returns (uint256)
3535
{
36-
return computeQuote(IMaglev(maglev), tokenIn, tokenOut, amountOut, false);
36+
return computeQuote(IEulerSwap(eulerSwap), tokenIn, tokenOut, amountOut, false);
3737
}
3838

3939
/// @dev High-level quoting function. It handles fees and performs
4040
/// state validation, for example that there is sufficient cash available.
41-
function computeQuote(IMaglev maglev, address tokenIn, address tokenOut, uint256 amount, bool exactIn)
41+
function computeQuote(IEulerSwap eulerSwap, address tokenIn, address tokenOut, uint256 amount, bool exactIn)
4242
internal
4343
view
4444
returns (uint256)
4545
{
46-
require(IEVC(evc).isAccountOperatorAuthorized(maglev.myAccount(), address(maglev)), OperatorNotInstalled());
46+
require(
47+
IEVC(evc).isAccountOperatorAuthorized(eulerSwap.myAccount(), address(eulerSwap)), OperatorNotInstalled()
48+
);
4749

48-
uint256 feeMultiplier = maglev.feeMultiplier();
49-
address vault0 = maglev.vault0();
50-
address vault1 = maglev.vault1();
51-
(uint112 reserve0, uint112 reserve1,) = maglev.getReserves();
50+
uint256 feeMultiplier = eulerSwap.feeMultiplier();
51+
address vault0 = eulerSwap.vault0();
52+
address vault1 = eulerSwap.vault1();
53+
(uint112 reserve0, uint112 reserve1,) = eulerSwap.getReserves();
5254

5355
// exactIn: decrease received amountIn, rounding down
5456
if (exactIn) amount = amount * feeMultiplier / 1e18;
5557

5658
bool asset0IsInput;
5759
{
58-
address asset0 = maglev.asset0();
59-
address asset1 = maglev.asset1();
60+
address asset0 = eulerSwap.asset0();
61+
address asset1 = eulerSwap.asset1();
6062

6163
if (tokenIn == asset0 && tokenOut == asset1) asset0IsInput = true;
6264
else if (tokenIn == asset1 && tokenOut == asset0) asset0IsInput = false;
6365
else revert UnsupportedPair();
6466
}
6567

66-
uint256 quote = binarySearch(maglev, reserve0, reserve1, amount, exactIn, asset0IsInput);
68+
uint256 quote = binarySearch(eulerSwap, reserve0, reserve1, amount, exactIn, asset0IsInput);
6769

6870
if (exactIn) {
6971
// if `exactIn`, `quote` is the amount of assets to buy from the AMM
@@ -85,7 +87,7 @@ contract MaglevPeriphery is IMaglevPeriphery {
8587
/// Although some curves may have more efficient closed-form solutions,
8688
/// this works with any monotonic curve.
8789
function binarySearch(
88-
IMaglev maglev,
90+
IEulerSwap eulerSwap,
8991
uint112 reserve0,
9092
uint112 reserve1,
9193
uint256 amount,
@@ -112,7 +114,8 @@ contract MaglevPeriphery is IMaglevPeriphery {
112114

113115
while (low < high) {
114116
uint256 mid = (low + high) / 2;
115-
if (dy == 0 ? maglev.verify(uint256(reserve0New), mid) : maglev.verify(mid, uint256(reserve1New))) {
117+
if (dy == 0 ? eulerSwap.verify(uint256(reserve0New), mid) : eulerSwap.verify(mid, uint256(reserve1New)))
118+
{
116119
high = mid;
117120
} else {
118121
low = mid + 1;

src/interfaces/IMaglev.sol renamed to src/interfaces/IEulerSwap.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
// SPDX-License-Identifier: UNLICENSED
22
pragma solidity >=0.8.0;
33

4-
interface IMaglev {
4+
interface IEulerSwap {
55
/// @notice Optimistically sends the requested amounts of tokens to the `to`
66
/// address, invokes `uniswapV2Call` callback on `to` (if `data` was provided),
77
/// and then verifies that a sufficient amount of tokens were transferred to
88
/// satisfy the swapping curve invariant.
99
function swap(uint256 amount0Out, uint256 amount1Out, address to, bytes calldata data) external;
1010

11-
/// @notice Approves the vaults to access the Maglev instance's tokens, and enables
11+
/// @notice Approves the vaults to access the EulerSwap instance's tokens, and enables
1212
/// vaults as collateral. Can be invoked by anybody, and is harmless if invoked again.
13-
/// Calling this function is optional: Maglev can be activated on the first swap.
13+
/// Calling this function is optional: EulerSwap can be activated on the first swap.
1414
function activate() external;
1515

1616
/// @notice Function that defines the shape of the swapping curve. Returns true iff
1717
/// the specified reserve amounts would be acceptable (ie it is above and to-the-right
1818
/// of the swapping curve).
1919
function verify(uint256 newReserve0, uint256 newReserve1) external view returns (bool);
2020

21-
// Maglev Accessors
21+
// EulerSwap Accessors
2222

2323
function curve() external view returns (bytes32);
2424
function vault0() external view returns (address);

src/interfaces/IMaglevPeriphery.sol renamed to src/interfaces/IEulerSwapPeriphery.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
// SPDX-License-Identifier: UNLICENSED
22
pragma solidity >=0.8.0;
33

4-
interface IMaglevPeriphery {
4+
interface IEulerSwapPeriphery {
55
/// @notice How much `tokenOut` can I get for `amountIn` of `tokenIn`?
6-
function quoteExactInput(address maglev, address tokenIn, address tokenOut, uint256 amountIn)
6+
function quoteExactInput(address eulerSwap, address tokenIn, address tokenOut, uint256 amountIn)
77
external
88
view
99
returns (uint256);
1010

1111
/// @notice How much `tokenIn` do I need to get `amountOut` of `tokenOut`?
12-
function quoteExactOutput(address maglev, address tokenIn, address tokenOut, uint256 amountOut)
12+
function quoteExactOutput(address eulerSwap, address tokenIn, address tokenOut, uint256 amountOut)
1313
external
1414
view
1515
returns (uint256);

0 commit comments

Comments
 (0)