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

Mainnet #29

Merged
merged 21 commits into from
Feb 16, 2024
Merged

Mainnet #29

merged 21 commits into from
Feb 16, 2024

Conversation

bxmmm1
Copy link
Contributor

@bxmmm1 bxmmm1 commented Jan 23, 2024

No description provided.

@bxmmm1 bxmmm1 self-assigned this Jan 23, 2024
/**
* @param withdrawalAmount is the assets amount, not shares
*/
function _checkDailyWithdrawalLimits(uint256 withdrawalAmount) internal {
Copy link
Contributor

Choose a reason for hiding this comment

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

function name needs to reflect the functionality -- updates state variables. suggestion: checkandUpdate...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed the logic for maxDeposit and maxRedeem so that we are compliant with the 4626 standard.

VaultStorage storage $ = _getPufferVaultStorage();

// If daily withdrawal limit is 0, then there is no limit
if ($.dailyWithdrawalLimit == 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

dailyWithdrawalLimit should be maxUInt instead for no limit case. (dailyWithdrawalLimit == maxUint --> return )

(maybe set dailyWithdrawalLimit in initializer to 0 for explicit declaration)

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is also fixed by changing the logic to use default 4626 limits, I'll resolve this after reviewing the new flow.

src/PufferVaultMainnet.sol Outdated Show resolved Hide resolved
src/PufferVaultMainnet.sol Outdated Show resolved Hide resolved
* @notice Allows the `msg.sender` to burn his shares
* @param shares The amount of shares to burn
*/
function burn(uint256 shares) public {
Copy link
Contributor

@shayanb shayanb Feb 2, 2024

Choose a reason for hiding this comment

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

Add restricted modifier to make it Pausable (consistent with the rest of the functions)

@@ -24,6 +24,7 @@ import { ILidoWithdrawalQueue } from "src/interface/Lido/ILidoWithdrawalQueue.so
import { IEigenLayer } from "src/interface/EigenLayer/IEigenLayer.sol";
import { IStrategy } from "src/interface/EigenLayer/IStrategy.sol";
import { Timelock } from "src/Timelock.sol";
import { IWETH } from "src/interface/Other/IWETH.sol";
Copy link
Contributor

Choose a reason for hiding this comment

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

Todo: integration testing with Weth, flows such as deposit, withdraw, redeem, etc

as well as some edge cases such as:

  • withdraw too much
  • different balances (weth, eth) v.s. diff withdrawalAmounts
  • withdrawalLimits changes

*/
function maxWithdraw(address owner) public view virtual override returns (uint256 maxAssets) {
uint256 remainingAssets = getRemainingAssetsDailyWithdrawalLimit();
uint256 maxUserAssets = _convertToAssets(balanceOf(owner), Math.Rounding.Floor);
Copy link
Contributor

Choose a reason for hiding this comment

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

Use previewRedeem() for consistency with the rest of the code.

erc4626Storage._asset = _WETH;

VaultStorage storage $ = _getPufferVaultStorage();
$.lastWithdrawalDay = uint64(block.timestamp / 1 days);
Copy link
Contributor

Choose a reason for hiding this comment

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

The daily limit needs to be set to 0, as in withdrawal is disabled.
(We need to explicitly set that to 0 here for readability and auditors.)


function getRemainingAssetsDailyWithdrawalLimit() public view virtual returns (uint96) {
VaultStorage storage $ = _getPufferVaultStorage();
return $.dailyAssetsWithdrawalLimit - $.assetsWithdrawnToday;
Copy link
Contributor

@shayanb shayanb Feb 6, 2024

Choose a reason for hiding this comment

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

In the scenario that the limit is not 0 and is set to 0, then this would be negative and revert, resulting in other functions failing.
add a check

  • $.dailyAssetsWithdrawalLimit < $.assetsWithdrawnToday return 0
  • else ...

@CheyenneAtapour CheyenneAtapour self-requested a review February 6, 2024 02:13
@@ -0,0 +1,97 @@
// SPDX-License-Identifier: GPL-3.0
Copy link
Contributor

Choose a reason for hiding this comment

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

@bxmmm1 is there a test that shows this upgrade works as expected? E.g. we can call the upgrade on the vault and try calling some of the functions in a test

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@JasonVranek
Copy link

LGTM, my main suggestions are to drop the swapping logic and keep the stETH redemption logic from V1 contracts.

@bxmmm1 bxmmm1 marked this pull request as ready for review February 15, 2024 07:04
@bxmmm1 bxmmm1 merged commit a40d950 into main Feb 16, 2024
4 checks passed
@bxmmm1 bxmmm1 deleted the feature/mainnet branch May 2, 2024 13:18
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.

4 participants