forked from sherlock-audit/2025-07-mellow-flexible-vaults
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSubvaultModule.sol
More file actions
49 lines (37 loc) · 1.38 KB
/
SubvaultModule.sol
File metadata and controls
49 lines (37 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.25;
import "../interfaces/modules/ISubvaultModule.sol";
import "../libraries/SlotLibrary.sol";
import "../libraries/TransferLibrary.sol";
import "./BaseModule.sol";
abstract contract SubvaultModule is ISubvaultModule, BaseModule {
bytes32 private immutable _subvaultModuleStorageSlot;
constructor(string memory name_, uint256 version_) {
_subvaultModuleStorageSlot = SlotLibrary.getSlot("SubvaultModule", name_, version_);
}
// View functions
/// @inheritdoc ISubvaultModule
function vault() public view returns (address) {
return _subvaultModuleStorage().vault;
}
// Mutable functions
/// @inheritdoc ISubvaultModule
function pullAssets(address asset, uint256 value) external nonReentrant {
address caller = _msgSender();
if (caller != vault()) {
revert NotVault();
}
TransferLibrary.sendAssets(asset, caller, value);
emit AssetsPulled(asset, caller, value);
}
// Internal functions
function __SubvaultModule_init(address vault_) internal onlyInitializing {
_subvaultModuleStorage().vault = vault_;
}
function _subvaultModuleStorage() internal view returns (SubvaultModuleStorage storage $) {
bytes32 slot = _subvaultModuleStorageSlot;
assembly {
$.slot := slot
}
}
}