Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic Implementation of Single Asset Vault #1

Merged
merged 16 commits into from
Aug 28, 2024
Merged

Basic Implementation of Single Asset Vault #1

merged 16 commits into from
Aug 28, 2024

Conversation

xhad
Copy link
Collaborator

@xhad xhad commented Aug 26, 2024

This is a basic implementation of the vault.

Features:

  1. Vaults may be deployed from the VaultFactory for ease of testing and usage.
  2. There is only one vault, a SingleVault, which is a SingleAsset 4626.
  3. Withdraws are standard 4626.
  4. Transactions from the Vault are done with the TimelockControllerUpgradeable contract, example in tests.

_grantRole(DEFAULT_ADMIN_ROLE, admin_);
_grantRole(OPERATOR_ROLE, operator_);
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we're to make the vault work with

karak
symbiotic
whatever kernel does in the future

we need to override totalAssets() and calculate things with something like the TVL modules in mellow:

https://github.com/mellow-finance/mellow-lrt/blob/main/src/modules/erc20/ERC20TvlModule.sol

https://github.com/mellow-finance/mellow-lrt/blob/main/src/modules/erc20/ERC20TvlModule.sol

We could launch this initial version without it and then make a v2 with this type of functionality.

Copy link
Contributor

@danoctavian danoctavian Aug 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would experiment with a prototype now on a prototype-branch (doesn't need to go into audit) just to validate quickly that approach would work well with karak and symbiotic.

Given that symbiotic already works on mellow , i expect it just works

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a SingleAsset vault. Would the tvl not be 1 to 1 with the underlying asset?

address[] memory proposers_,
address[] memory executors_
) internal pure {
require(asset_ != IERC20(address(0)), "Asset cannot be zero address");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should use named errors like ZeroAddress()

constructor() {
_disableInitializers();
}

Copy link
Contributor

@danoctavian danoctavian Aug 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

product question: do we want to be able to puase withdrawals?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should not pause withdraws for this version of the vault.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danoctavian This vault being as plain vanilla OZ as possible is safer for the expedited timeline for BSC Kernel.

src/VaultFactory.sol Outdated Show resolved Hide resolved
IERC20
} from "src/Common.sol";

contract VaultFactory is AccessControlUpgradeable {
Copy link
Contributor

@danoctavian danoctavian Aug 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thinking what's the value of the factory beyond cheking for symbol duplicates now

One thing is the vaults as they are are vulnerable to donation attacks because of how ERC4626Upgradeable is built

So we can consider boostrapping all vaults at creation time in the factory.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having a factory makes it easier to deploy a Vault

Copy link
Collaborator Author

@xhad xhad Aug 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danoctavian Thank you. I added a bootstrap to the factory.

dcee010

Also note that as of v5 of ERC4626 Upgradeable, OZ claims to have mitigated the donation attack.

https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/blob/723f8cab09cdae1aca9ec9cc1cfa040c2d4b06c1/contracts/token/ERC20/extensions/ERC4626Upgradeable.sol#L33-L34

This is something we can point to for any bug bounty requests.


import {ISingleVault} from "src/ISingleVault.sol";

contract SingleVault is ISingleVault, ERC4626Upgradeable, TimelockControllerUpgradeable, ReentrancyGuardUpgradeable {
Copy link
Contributor

@danoctavian danoctavian Aug 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with regards to the whitelistTx functionality:

Just whileisting txdata blob is too simple to be useful

We'd need to be able to parse out the selector and check the target and against. a whitelist to make it useful to validate in a general way things like:

someSymbioticVault.deposit(amount, receiver)

something akin to this https://github.com/mellow-finance/mellow-lrt/blob/main/src/validators/DefaultBondValidator.sol

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering how we engaged Zokyo for delivery of code for yesterday, Module integration will have to wait until after this initial version.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danoctavian I really like the modular design of the mellow vaults.

@xhad xhad requested a review from danoctavian August 27, 2024 10:48
@xhad xhad merged commit a0bccc0 into main Aug 28, 2024
2 checks passed
@xhad xhad deleted the feature/upgrade branch November 7, 2024 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants