# Rebalance will fail due to low precision of percentages

AssetManager.rebalance uses base-point percentages (0.01% precision), leaving dust that trips the zero-balance require and reverts rebalancing.

- Payout: Audit contest
- Severity: medium
- Program: Union Finance
- Found by: cmichel
- Disclosed: 2021-12-08
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2021-10-union-findings/issues/64
- Library page: https://bugbountylibrary.com/r/c4%3A2021-10-union%3AM-02
- Tags: area:web3 domain:web3 impact:dos kind:contest platform:code4rena sev:medium tech:solidity vuln:accounting-error vuln:precision-loss

**Target:** AssetManager.rebalance Solidity contract
**Root cause:** Percentages are in base points (1e4), so integer division of tokenSupply by percentages leaves remainder dust in the contract; the final require(balanceOf == 0) then reverts.
**Steps:**
1. Set percentages to `[5000, 5000]` when the last market does not support the token.
2. Withdraw all tokens so `tokenSupply = 10,001`.
3. Compute `amountToDeposit = 10,001 * 5,000 / 10,000 = 5,000` per market.
4. Two deposits leave `10,001 - 2*5,000 = 1` dust.
5. `require(token.balanceOf(address(this)) == 0)` reverts, so rebalance fails.
**How found:** Code review of the final zero-balance require combined with reasoning about integer division precision of base-point percentages.
**Insight:** When a function asserts an exact zero balance after proportional integer splits, check whether the split denominator (e.g. 1e4 base points) is coarser than token decimals—dust will always remain.
