-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from symbioticfi/tests
Add vault configurator
- Loading branch information
Showing
37 changed files
with
3,389 additions
and
192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity 0.8.25; | ||
|
||
import {VaultFactory} from "src/contracts/VaultFactory.sol"; | ||
import {DelegatorFactory} from "src/contracts/DelegatorFactory.sol"; | ||
import {SlasherFactory} from "src/contracts/SlasherFactory.sol"; | ||
import {Vault} from "src/contracts/vault/Vault.sol"; | ||
|
||
import {IVaultConfigurator} from "src/interfaces/IVaultConfigurator.sol"; | ||
|
||
contract VaultConfigurator is IVaultConfigurator { | ||
/** | ||
* @inheritdoc IVaultConfigurator | ||
*/ | ||
address public immutable VAULT_FACTORY; | ||
|
||
/** | ||
* @inheritdoc IVaultConfigurator | ||
*/ | ||
address public immutable DELEGATOR_FACTORY; | ||
|
||
/** | ||
* @inheritdoc IVaultConfigurator | ||
*/ | ||
address public immutable SLASHER_FACTORY; | ||
|
||
constructor(address vaultFactory, address delegatorFactory, address slasherFactory) { | ||
VAULT_FACTORY = vaultFactory; | ||
DELEGATOR_FACTORY = delegatorFactory; | ||
SLASHER_FACTORY = slasherFactory; | ||
} | ||
|
||
/** | ||
* @inheritdoc IVaultConfigurator | ||
*/ | ||
function create(InitParams memory params) public returns (address, address, address) { | ||
address vault = VaultFactory(VAULT_FACTORY).create(params.version, params.owner, false, ""); | ||
|
||
params.vaultParams.delegator = DelegatorFactory(DELEGATOR_FACTORY).create( | ||
params.delegatorIndex, true, abi.encode(vault, params.delegatorParams) | ||
); | ||
|
||
if (params.withSlasher) { | ||
params.vaultParams.slasher = SlasherFactory(SLASHER_FACTORY).create( | ||
params.slasherIndex, true, abi.encode(vault, params.slasherParams) | ||
); | ||
} | ||
|
||
Vault(vault).initialize(params.version, params.owner, abi.encode(params.vaultParams)); | ||
|
||
return (vault, params.vaultParams.delegator, params.vaultParams.slasher); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.