Skip to content

Commit 6267537

Browse files
committed
VaultFactory
1 parent 51b4f8c commit 6267537

File tree

4 files changed

+61
-1
lines changed

4 files changed

+61
-1
lines changed

remappings.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
solmate/=lib/solmate/src

src/Owners.sol

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity =0.8.26;
3+
4+
import {ERC721} from "solmate/tokens/ERC721.sol";
5+
import {Owned} from "solmate/auth/Owned.sol";
6+
7+
contract Owners is ERC721, Owned {
8+
9+
constructor() ERC721("Repo Owners", "RO") Owned(msg.sender) {
10+
11+
}
12+
13+
function mint(address to, uint256 id) public onlyOwner returns (uint) {
14+
_mint(to, id);
15+
return id;
16+
}
17+
18+
function tokenURI(uint256 id) public pure override returns (string memory) {
19+
return string(abi.encodePacked("https://api.merit.systems/owner/", id));
20+
}
21+
22+
}

src/Vault.sol

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity =0.8.26;
33

4-
contract Vault {
4+
import {ERC4626} from "solmate/tokens/ERC4626.sol";
5+
import {ERC20} from "solmate/tokens/ERC20.sol";
6+
7+
import {Owners} from "./Owners.sol";
8+
9+
contract Vault is ERC4626 {
10+
11+
constructor(
12+
uint ownerId,
13+
ERC20 _asset,
14+
string memory _name,
15+
string memory _symbol
16+
) ERC4626(_asset, _name, _symbol) {}
17+
18+
function totalAssets() public override view returns (uint256) {
19+
return asset.balanceOf(address(this));
20+
}
521

622
}

src/VaultFactory.sol

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity =0.8.26;
3+
4+
import {ERC20} from "solmate/tokens/ERC20.sol";
5+
6+
import {Owners} from "./Owners.sol";
7+
import {Vault} from "./Vault.sol";
8+
9+
contract VaultFactory {
10+
11+
Owners public owners;
12+
13+
constructor(Owners _owners) {
14+
owners = _owners;
15+
}
16+
17+
function createVault(address owner, ERC20 asset) public returns (Vault vault) {
18+
uint _owner = owners.mint(owner, 2);
19+
return new Vault(_owner, asset, "", "");
20+
}
21+
}

0 commit comments

Comments
 (0)