<!-- canonical: https://0xsimao.com/findings/beraborrow-i-view-work-certain-conditions -->

# Some view functions will not work under certain conditions

Low/Info · Sherlock · CDP stablecoin · 25th April, 2025

Finding L-7 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::getStrategyCR()`, `ManagedLeveragedVault::exposurePositionWeight()` and `ManagedLeveragedVault:: getStrategyLeverage()` may revert.

## Vulnerability Detail

The functions below when there is no debt or position, most likely when the Den hasn't been opened or when the Vault was just deployed.
```solidity
function getStrategyCR() public view returns (uint256) {
    return (getMarginValue() + getExposureBalance()) * WAD / getDebtBalance();
}

function exposurePositionWeight() public view returns (uint256) {
    return getExposureValue() * WAD / getCurrentPositionValue();
}

function collateralPositionWeight() public view returns (uint256) {
    return WAD - exposurePositionWeight();
}

function getStrategyLeverage() public view returns (uint256) {
    uint256 positionValue = getCurrentPositionValue();
    return positionValue * WAD / (positionValue - getDebtBalance());
}
```

## Impact

View function reverts.

## Code Snippet

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

## Tool Used

Manual Review

## Recommendation

Handle these cases.

---

Related findings:

- [`PreDepositVault::sweep()` uses `address.transfer` which does not work for certain wallets](https://0xsimao.com/findings/gaib-deposit-sweep-transfer-wallets): GAIB Pre-Vaults
- [`FlashRolloverLoan_G5` will not work for certain tokens due to not setting the approval to `0` after repaying a loan](https://0xsimao.com/findings/teller-finance-flash-rollover-approval-repaying): Teller Finance
