Skip to content

Commit 79158fe

Browse files
committed
Make factory check that vaults are created by EVK factory
spearbit #9
1 parent fcd9fcf commit 79158fe

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

script/DeployProtocol.s.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ contract DeployProtocol is ScriptUtil {
1717
string memory json = _getJsonFile(inputScriptFileName);
1818

1919
address evc = vm.parseJsonAddress(json, ".evc");
20+
address factory = vm.parseJsonAddress(json, ".factory");
2021

2122
vm.startBroadcast(deployerAddress);
2223

23-
new EulerSwapFactory(evc);
24+
new EulerSwapFactory(evc, factory);
2425
new EulerSwapPeriphery();
2526

2627
vm.stopBroadcast();

script/json/DeployProtocol_input.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"evc": "0x0C9a3dd6b8F28529d72d7f9cE918D493519EE383"
3-
}
2+
"evc": "0x0C9a3dd6b8F28529d72d7f9cE918D493519EE383",
3+
"factory": "0xF75548aF02f1928CbE9015985D4Fcbf96d728544"
4+
}

src/EulerSwapFactory.sol

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ pragma solidity ^0.8.27;
44
import {IEulerSwapFactory, IEulerSwap} from "./interfaces/IEulerSwapFactory.sol";
55
import {EulerSwap} from "./EulerSwap.sol";
66
import {EVCUtil} from "ethereum-vault-connector/utils/EVCUtil.sol";
7+
import {GenericFactory} from "evk/GenericFactory/GenericFactory.sol";
78

89
/// @title EulerSwapFactory contract
910
/// @custom:security-contact [email protected]
@@ -13,6 +14,8 @@ contract EulerSwapFactory is IEulerSwapFactory, EVCUtil {
1314
address[] public allPools;
1415
/// @dev Mapping between euler account and deployed pool that is currently set as operator
1516
mapping(address eulerAccount => address operator) public eulerAccountToPool;
17+
/// @dev Vaults must be deployed by this factory
18+
address public immutable evkFactory;
1619

1720
event PoolDeployed(
1821
address indexed asset0,
@@ -34,15 +37,22 @@ contract EulerSwapFactory is IEulerSwapFactory, EVCUtil {
3437
error Unauthorized();
3538
error OldOperatorStillInstalled();
3639
error OperatorNotInstalled();
40+
error InvalidVaultImplementation();
3741

38-
constructor(address evc) EVCUtil(evc) {}
42+
constructor(address evc, address evkFactory_) EVCUtil(evc) {
43+
evkFactory = evkFactory_;
44+
}
3945

4046
/// @inheritdoc IEulerSwapFactory
4147
function deployPool(IEulerSwap.Params memory params, IEulerSwap.CurveParams memory curveParams, bytes32 salt)
4248
external
4349
returns (address)
4450
{
4551
require(_msgSender() == params.eulerAccount, Unauthorized());
52+
require(
53+
GenericFactory(evkFactory).isProxy(params.vault0) && GenericFactory(evkFactory).isProxy(params.vault1),
54+
InvalidVaultImplementation()
55+
);
4656

4757
EulerSwap pool = new EulerSwap{salt: keccak256(abi.encode(params.eulerAccount, salt))}(params, curveParams);
4858

test/EulerSwapFactoryTest.t.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ contract EulerSwapFactoryTest is EulerSwapTestBase {
1313
super.setUp();
1414

1515
vm.prank(creator);
16-
eulerSwapFactory = new EulerSwapFactory(address(evc));
16+
eulerSwapFactory = new EulerSwapFactory(address(evc), address(factory));
1717
}
1818

1919
function testDeployPool() public {

0 commit comments

Comments
 (0)