@@ -3,10 +3,10 @@ pragma solidity ^0.8.27;
3
3
4
4
import {IEVC} from "evc/interfaces/IEthereumVaultConnector.sol " ;
5
5
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 " ;
8
8
9
- contract MaglevPeriphery is IMaglevPeriphery {
9
+ contract EulerSwapPeriphery is IEulerSwapPeriphery {
10
10
address private immutable evc;
11
11
12
12
constructor (address evc_ ) {
@@ -18,52 +18,54 @@ contract MaglevPeriphery is IMaglevPeriphery {
18
18
error InsufficientReserves ();
19
19
error InsufficientCash ();
20
20
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 )
23
23
external
24
24
view
25
25
returns (uint256 )
26
26
{
27
- return computeQuote (IMaglev (maglev ), tokenIn, tokenOut, amountIn, true );
27
+ return computeQuote (IEulerSwap (eulerSwap ), tokenIn, tokenOut, amountIn, true );
28
28
}
29
29
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 )
32
32
external
33
33
view
34
34
returns (uint256 )
35
35
{
36
- return computeQuote (IMaglev (maglev ), tokenIn, tokenOut, amountOut, false );
36
+ return computeQuote (IEulerSwap (eulerSwap ), tokenIn, tokenOut, amountOut, false );
37
37
}
38
38
39
39
/// @dev High-level quoting function. It handles fees and performs
40
40
/// 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 )
42
42
internal
43
43
view
44
44
returns (uint256 )
45
45
{
46
- require (IEVC (evc).isAccountOperatorAuthorized (maglev.myAccount (), address (maglev)), OperatorNotInstalled ());
46
+ require (
47
+ IEVC (evc).isAccountOperatorAuthorized (eulerSwap.myAccount (), address (eulerSwap)), OperatorNotInstalled ()
48
+ );
47
49
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 ();
52
54
53
55
// exactIn: decrease received amountIn, rounding down
54
56
if (exactIn) amount = amount * feeMultiplier / 1e18 ;
55
57
56
58
bool asset0IsInput;
57
59
{
58
- address asset0 = maglev .asset0 ();
59
- address asset1 = maglev .asset1 ();
60
+ address asset0 = eulerSwap .asset0 ();
61
+ address asset1 = eulerSwap .asset1 ();
60
62
61
63
if (tokenIn == asset0 && tokenOut == asset1) asset0IsInput = true ;
62
64
else if (tokenIn == asset1 && tokenOut == asset0) asset0IsInput = false ;
63
65
else revert UnsupportedPair ();
64
66
}
65
67
66
- uint256 quote = binarySearch (maglev , reserve0, reserve1, amount, exactIn, asset0IsInput);
68
+ uint256 quote = binarySearch (eulerSwap , reserve0, reserve1, amount, exactIn, asset0IsInput);
67
69
68
70
if (exactIn) {
69
71
// if `exactIn`, `quote` is the amount of assets to buy from the AMM
@@ -85,7 +87,7 @@ contract MaglevPeriphery is IMaglevPeriphery {
85
87
/// Although some curves may have more efficient closed-form solutions,
86
88
/// this works with any monotonic curve.
87
89
function binarySearch (
88
- IMaglev maglev ,
90
+ IEulerSwap eulerSwap ,
89
91
uint112 reserve0 ,
90
92
uint112 reserve1 ,
91
93
uint256 amount ,
@@ -112,7 +114,8 @@ contract MaglevPeriphery is IMaglevPeriphery {
112
114
113
115
while (low < high) {
114
116
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
+ {
116
119
high = mid;
117
120
} else {
118
121
low = mid + 1 ;
0 commit comments