<!-- canonical: https://0xsimao.com/findings/beraborrow-i-sol-deposit-slippage-control -->

# `ManagedLeveragedVault.sol::deposit()` is missing slippage control

Medium · Sherlock · CDP stablecoin · 25th April, 2025

Finding M-1 of the Beraborrow Managed Dens security review.

- Protocol: https://www.beraborrow.com/
- Report: /reports/beraborrow-i
- Source: https://1570492309-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FffzDCMBDa391vIMqruBP%2Fuploads%2FUKDtjc6Dkn6P6i35j5H1%2FManaged%20Leverage%20Vaults%20v0%20private%20audit%20Sherlock.pdf?alt=media&token=c7304efa-8040-4ed0-9a98-dc949af28a85

---

## Summary

`ManagedLeveragedVault.sol::deposit()` doesn't have slippage control for the shares minted.

## Vulnerability Detail

The deposit function is as follows:
```solidity
function deposit(uint256 assets, address receiver, AddCollParams calldata params)
    public
    notPaused
    nonReentrant
    returns (uint256 shares)
{
    BoycoVaultStorage storage b$ = _getBoycoVaultStorage();

    shares = _deposit(assets, receiver);

    IERC20(asset()).forceApprove(address(b$.collVault), assets);
    uint256 collVaultShares = b$.collVault.deposit(assets, address(this));

    if (collVaultShares < params.minSharesOut) revert VaultSlippage(params.minSharesOut, collVaultShares);

    _addColl(collVaultShares, params.upperHint, params.lowerHint);
}
```
Note that there is no slippage control on the shares amount minted, whose ratio may change depending on several protocol actions or price updates. There is slippage control for the `collVaultShares`, but this may still mean a lower amount of shares as they are not 100% related.

## Impact

User takes slippage losses.

## Code Snippet

https://github.com/sherlock-audit/2025-04-beraborrow-vault-update/pull/1/files#diff-2d972f52027e0ba1065b2de2b424416244bfef9e2a79d2604e1687867f72c91eR273

## Tool Used

Manual Review

## Recommendation

Add slippage control to shares.

---

Related findings:

- [The basic strategy does not have slippage control when withdrawing which may lead to arbitrage](https://0xsimao.com/findings/maple-finance-iv-slippage-control-withdrawing-arbitrage): Maple Cash Strategies
- [Missing fee refund on Batch.sol](https://0xsimao.com/findings/clip-finance-i-fee-refund-batch-sol): Clip Finance Strategies
- [deTokenize() is missing access control, anyone can burn other people's nfts](https://0xsimao.com/findings/metazero-i-tokenize-access-control-burn): MetaZero Omnichain NFTs
- [Uniswap asset managers are missing slippage checks](https://0xsimao.com/findings/singularity-uniswap-managers-slippage-checks): Singularity
