Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions TODO
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
* ConstantSum: incorporate price multipliers in quote methods
* natspec
* permit2 instead of regular approval: measure gas savings
* in constructor, check the two vaults have the correct EVC() return value
* maybe even that they were created by the EVK factory?
? a really small swap could fail because deposit() results in 0 shares, which EVK fails on. call convertToShares() first? Seems like overkill
? pause guardian
? how should aggregators find instances
Expand Down
5 changes: 5 additions & 0 deletions src/MaglevBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ abstract contract MaglevBase is IMaglevBase, EVCUtil {
error BadFee();
error InsufficientReserves();
error InsufficientCash();
error DifferentEVC();

modifier nonReentrant() {
require(locked == 0, Locked());
Expand All @@ -48,6 +49,10 @@ abstract contract MaglevBase is IMaglevBase, EVCUtil {
constructor(BaseParams memory params) EVCUtil(params.evc) {
require(params.fee < 1e18, BadFee());

address vault0Evc = IEVault(params.vault0).EVC();
require(vault0Evc == IEVault(params.vault1).EVC(), DifferentEVC());
require(vault0Evc == params.evc, DifferentEVC());

vault0 = params.vault0;
vault1 = params.vault1;
asset0 = IEVault(vault0).asset();
Expand Down
19 changes: 18 additions & 1 deletion test/EulerSwap.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {TestERC20} from "evk-test/unit/evault/EVaultTestBase.t.sol";
import {IEVault} from "evk/EVault/IEVault.sol";
import {MaglevTestBase} from "./MaglevTestBase.t.sol";

import {MaglevEulerSwap as Maglev} from "../src/MaglevEulerSwap.sol";
import {MaglevEulerSwap as Maglev, MaglevBase} from "../src/MaglevEulerSwap.sol";

contract EulerSwapTest is MaglevTestBase {
Maglev public maglev;
Expand Down Expand Up @@ -41,6 +41,23 @@ contract EulerSwapTest is MaglevTestBase {
maglev.configure();
}

function test_different_EVC() public {
vm.expectRevert(MaglevBase.DifferentEVC.selector);

new Maglev(
MaglevBase.BaseParams({
evc: address(makeAddr("RANDOM_EVC")),
vault0: address(eTST),
vault1: address(eTST2),
myAccount: holder,
debtLimit0: 50e18,
debtLimit1: 50e18,
fee: 0
}),
Maglev.EulerSwapParams({priceX: 1e18, priceY: 1e18, concentrationX: 4e18, concentrationY: 0.85e18})
);
}

function test_basicSwap_exactIn() public monotonicHolderNAV {
uint256 amountIn = 1e18;
uint256 amountOut = maglev.quoteExactInput(address(assetTST), address(assetTST2), amountIn);
Expand Down
Loading