> For the complete documentation index, see [llms.txt](https://calnix.gitbook.io/eth-dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://calnix.gitbook.io/eth-dev/yield-mentorship-2022/math-logic-+-internal-fn.md).

# math logic + internal fn

https\://github.com/hashedMae/mentorshipProjects/pull/4

Instead of repeating math logic, you should call the `convertToAssets` function.

Even better, for gas cost. You should put the logic on an internal `_convertToAssets` function, and call `_convertToAssets` from the external `convertToAssets` (which becomes a user-facing function), `mint` and `redeem`.

The same pattern should be followed for `convertToShares`, `deposit` and `withdraw`.
