# Downcasts that silently truncate, and gaming which branch accrueInterest takes

Mentorship Series #22 · 15 January 2026 · [@0xfirefist](https://x.com/0xFireFist) · Panoptic · Code4rena

Mentorship Series · [The Contest Academy](https://0xsimao.com/the-contest-academy) · 0xSimao

---

We continued the Panoptic [contest](https://code4rena.com/audits/2025-12-panoptic-next-core) on Code4rena.

**Lesson Summary:**

- Downcasting truncates the number — watch closely for such casts.
- ERC-4626 vaults check the asset amount for zero, not the shares.
- Check the cast in the withdraw function — can it cause a problem? Verdict: fine.
- Play with numbers across every branch of the `accrueInterest` function.
- Can someone call a function that accrues interest and hit another \`owner\` through the \`!isDeposit\` branch, making them burn their shares?
- User has enough balance.
- User does not have enough balance and it is not a deposit.
- User does not have enough balance but it is a deposit: transfer ---> deposit. Search for any way a user could game the accrual of interest.

https://youtu.be/HTduz1gAmTU

Session video: https://youtu.be/HTduz1gAmTU

---

Newer: [Precision in the trapezoidal borrow-rate curve, and the Yearn post-mortem behind it](https://0xsimao.com/the-contest-academy/mentorship-series-23) · Older: [Uniswap V4 mechanics: unlock callbacks, the sign of a delta, and sync before settle](https://0xsimao.com/the-contest-academy/mentorship-series-21)
