-
Notifications
You must be signed in to change notification settings - Fork 96
[Vault] Simplify VaultCore. #2714
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
base: master
Are you sure you want to change the base?
Conversation
…emove WETH dependencies
…implify total value calculations
… and clean up comments in VaultCore
…ctions, simplifying the codebase.
…implify the codebase.
… improve clarity by removing deprecated functions and updating asset handling methods.
…itialization by using address(0) for backing asset.
…move deprecated asset handling
…rategy handling for backing asset
…address, simplifying price retrieval and enhancing clarity
…nstructors for improved clarity and functionality
…ved clarity and consistency
…y by removing unused variables and consolidating test cases
…nd consolidating test cases
…d consolidating test cases
…ables and consolidating test cases
…ate mint and redeem amounts for consistency
…fy asset handling
…et address, update test fixtures to use USDC instead of USDS, and simplify Dripper and VaultValueChecker tests by removing unused variables and consolidating logic.
…ltInitializer, and VaultStorage
sparrowDom
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Posting intermittent review comments
| _swap(rewardTokens[i], _rewardTo, priceProvider); | ||
| // This harvester contract is not used anymore. Keeping the code | ||
| // for passing test deployment. Safe to use address(0x1) as oracle. | ||
| _swap(rewardTokens[i], _rewardTo, IOracle(address(0x1))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have we decided to keep the functionality to allow for the protocol to swap the reward token? Afaik we handle most of the reward tokens via a multisig contract these days.
I guess the question is why do we still need this _doSwap implementation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AbstractHarvester is not used anymore, but in order to keep the PR simple I didn't deleted the file.
I agree this is something we shouldn't keep _doSwap and preferably remove AbstractHarvester contract.
|
|
||
| function totalValue() external view returns (uint256 value); | ||
|
|
||
| function checkBalance(address _asset) external view returns (uint256); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't comment on an item 1 line below. Are we keeping the calculateRedeemOutputs for backward compatibility?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so yes. However it could lighten the code if we can remove it, and I'm in favor of it.
I created this doc where I'm not sure if we should/could get rid of some part of the code: https://www.notion.so/originprotocol/Can-we-get-rid-of-it-2c484d46f53c8024a9eec3b6260ef8f4?source=copy_link
|
|
||
| function netOusdMintedForStrategy() external view returns (int256); | ||
|
|
||
| function setDripper(address _dripper) external; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can remove these 2 dripper functions as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only setDripper can be removed, dripper is used in OETHBaseHarvester.
Changed in this commit: b61e10e
| ); | ||
| require(_assets.length == _amounts.length, "Parameter length mismatch"); | ||
| require( | ||
| _assets.length == 1 && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reason that assets and amounts remain arrays?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created this doc where I'm not sure if we should/could get rid of some part of the code: https://www.notion.so/originprotocol/Can-we-get-rid-of-it-2c484d46f53c8024a9eec3b6260ef8f4?source=copy_link. But I'm in favor of simplification here.
| using StableMath for uint256; | ||
|
|
||
| address public immutable weth; | ||
| uint256 public wethAssetIndex; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should deprecate this to not mess up the storage slot order.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for weth as this is an immutable.
Really really nice catch for wethAssetIndex!! Fixed in this commit: 39bbbfb.
| * @title Origin Sonic VaultAdmin contract on Sonic | ||
| * @author Origin Protocol Inc | ||
| */ | ||
| contract OSonicVaultAdmin is OETHVaultAdmin { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need this contract?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I get it.
OSonicVaultAdmin is deployed at this address and still used in prod, so I would say yes.
| * @title OUSD VaultAdmin Contract | ||
| * @author Origin Protocol Inc | ||
| */ | ||
| contract OUSDVaultAdmin is VaultAdmin { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a reason we have a separate OUSDVaultAdmin contract?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, to have a clear distinction between what is a commun basis VaultAdmin and VaultCore, and what is product itself, like OUSDVaultAdmin, OETHVaultAdmin. This is to avoid unclear naming, like in the current situation, VaultCore represent OUSD vault, while OETH vault is named OETHVault.
To enforce this, I marked VaultCore and VaultAdmin as abstract.
Description
This pull request makes substantial changes to the
IVaultinterface and related contracts, primarily to simplify asset and strategy management, remove unused or deprecated functionality, and update how price oracles are referenced. The changes affect core vault logic, mock contracts, strategies, and event emissions. The most important changes are grouped by theme below.Vault Interface Simplification and Refactoring
IVault, including asset-specific strategy management, swapper/oracle slippage controls, and price provider references, to streamline the interface. This includes the removal ofpriceProvider,setPriceProvider, swap-related functions, and asset-specific strategy functions. [1] [2] [3] [4] [5] [6] [7]setDefaultStrategy,defaultStrategy, andDefaultStrategyUpdated. [1] [2]backingAsset()as a public view function.weth()to the end of the interface and ensured it is still accessible.Oracle and Price Provider Handling
BridgedWOETHStrategyand mocks). [1] [2] [3] [4] [5] [6] [7] [8]IVault.priceProvider(). [1] [2] [3] [4] [5] [6]Asset and Strategy Management
backingAssetinstead of asset arrays or indices, and simplified asset support logic. [1] [2] [3] [4] [5]Miscellaneous Updates
OETHVaultcontract.These changes significantly modernize and simplify the vault and strategy interfaces, improve clarity, and reduce unused code, paving the way for easier maintenance and future upgrades.
These changes help reduce contract complexity, remove unused features, and prepare the codebase for future upgrades.
Code Change Checklist
To be completed before internal review begins:
Internal review:
Deploy checklist
Two reviewers complete the following checklist: