<!-- canonical: https://0xsimao.com/findings/fuji-finance-transformation-preview-mint-debt -->

# Wrong transformation in function previewMintDebt(...)

Crit/High · Three Sigma · Lending aggregator · 6th May, 2023

Finding 3S-FUJI-H05 of the Fuji Finance security review.

- Report: /reports/fuji-finance
- Source: https://cdn.sanity.io/files/qoqld077/staging/32181a28eac3175d15fb8924d249bb0d91ca350c.pdf

---

### Description

In the BorrowingVault.sol the function previewMintDebt(...) is supposed to take an
amount of shares and turn them into an amount of debt. Currently it is taking the shares as
if they were debt and turning them to shares.

```solidity
function previewMintDebt(uint256 shares) public view override returns
(uint256 debt) {
    return _convertDebtToShares(shares, Math.Rounding.Down);
}
```

### Recomendation

Change the function to use _convertToDebt(...) instead of _convertDebtToShares(...), as following

```solidity
function previewMintDebt(uint256 shares) public view override returns
(uint256 debt) {
    return _convertToDebt(shares, Math.Rounding.Down);
}
```

### Status

Addressed here: [Fujicracy/fuji-v2#624](https://github.com/Fujicracy/fuji-v2/pull/624)

---

Related findings:

- [Function cancelMint can be frontrunned to grief a validator](https://0xsimao.com/findings/m-0-mint-frontrunned-grief-validator): M^0 Minter Gateway
- [In function mint() and lzReceive(), _safeMint() is recommended over _mint(), which performs additional checks](https://0xsimao.com/findings/metazero-i-mint-recommended-performs-additional): MetaZero Omnichain NFTs
- [Wrong comment in Standard Governor's execute function](https://0xsimao.com/findings/m-0-comment-standard-governor-function): M^0 Minter Gateway
- [Liquidations can be prevented by frontrunning and liquidating 1 debt (or more) due to wrong assumption in POS_MANAGER](https://0xsimao.com/findings/init-capital-ii-liquidations-frontrunning-debt-assumption): INIT Capital
