# Rounding errors can cause ERC20RebaseDistributor transfers and mints to fail for underflow

Rounding in ERC20RebaseDistributor share math makes transfers/mints to rebasing addresses underflow-revert, temporarily bricking token operations and blocking exitRebase.

- Payout: Contest reward
- Severity: medium
- Program: Ethereum Credit Guild
- Credited: 3docSec
- Disclosed: 2024-02-22
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2023-12-ethereumcreditguild-findings/issues/294
- Library page: https://bugbountylibrary.com/r/c4%3A2023-12-ethereumcreditguild%3AM-23
- Tags: domain:web3 impact:dos kind:contest platform:code4rena sev:medium tech:evm tech:solidity technique:source-review vuln:dos vuln:precision-loss

**Target:** ERC20RebaseDistributor token contract (transfer/mint/exitRebase)
**Root cause:** Share deltas computed via multiple floor divisions (balance*START_PRICE/sharePrice) can yield toSharesAfter one wei below stored nShares, and _unmintedRebaseRewards - amount can underflow, both reverting.
**Steps:**
1. Deploy CreditToken; mint 100e18 to addr1 and call `enterRebase()`.
2. Mint 6e11 to addr2 and `distribute(6e11)`; warp 2s; mint 3e12 and `distribute(3e12)`.
3. Mint 1e20 to addr3 and call `transfer(addr1, 1e20)` -> reverts on `toSharesAfter - rebasingStateTo.nShares`.
4. `mint(addr1, 1e20)` also reverts; addr1 `exitRebase()` reverts; `transferFrom(addr1, addr3, ...)` reverts.
5. Second PoC: mint 100e18 to `to`, `enterRebase()`, `distribute(1 ether)`, warp 1s, then `transfer(to, 0)` reverts.
**How found:** Code-reading of share/balance conversion math; noticed multiple floor divisions in `_balance2shares`/`_shares2balance` could round stored nShares above recomputed shares, then built Foundry PoCs to trigger the subtraction underflow.
**Exploitation:** Permissionless small `distribute` calls with tuned timing/amounts can extend the DoS window; rebasing users cannot transfer, mint, or exitRebase, potentially blocking liquidation or unstaking from SurplusGuildMinter.
**Escalation:** Repeated small distributions with chosen timing prolong the underflow window beyond the ~31s natural decay.
**Insight:** When a token stores shares but recomputes them from balance via chained floor divisions, the recomputed value can drift below the stored value; test zero-amount and dust transfers to rebasing accounts across interpolated price changes.
