Skip to content

Slippage vault#374

Open
maruf0011 wants to merge 4 commits intomasterfrom
slippage-vault
Open

Slippage vault#374
maruf0011 wants to merge 4 commits intomasterfrom
slippage-vault

Conversation

@maruf0011
Copy link
Copy Markdown
Collaborator

  • Implementation
  • Existing test coverage
  • New test specific to slippage vault.

@maruf0011 maruf0011 requested a review from larryob October 24, 2023 14:22
Copy link
Copy Markdown
Contributor

@larryob larryob left a comment

Choose a reason for hiding this comment

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

Looking good, needs a couple of changes.

Comment on lines +8 to +10
import {Vault} from "src/vaults/Vault.sol";
import {VaultV2} from "src/vaults/VaultV2.sol";
import {NftGate} from "src/vaults/NftGate.sol";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Some unused imports here.


function harvest(Strategy[] calldata strategyList) external virtual override onlyRole(HARVESTER) {
// Profit must not be unlocking
// require(block.timestamp >= lastHarvest + LOCK_INTERVAL, "BV: profit unlocking");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Probably want to remove this comment

// Used to store the total profit accrued by the strategies.
uint256 totalProfitAccrued;

for (uint256 i = 0; i < strategyList.length; i = uncheckedInc(i)) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It'd be nice if we could pull the logic for harvesting a single strategy into its own function.

* @dev See {IERC4262-deposit}.
*/
function deposit(uint256 assets, address receiver) public virtual override whenNotPaused returns (uint256) {
_harvestAll();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Instead of calling_harvestAll(), we should be getting the total strategy holdings before/after we deposit into the strategies. The difference between these two numbers is what should be passed to previewDeposit

return vaultTVL() - oldTVL;
}

function _deposit(address caller, address receiver, uint256 assets, uint256 shares) internal virtual override {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We can't use _depositIntoStrategies. We need to increment totalStrategyHoldings by the exact amount that actually got into the strategies.

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