# Rounding error in stepDuration calculations.

Integer division truncation in SecondSwap StepVesting stepDuration either rounds to zero, bricking claim(), or shortens the vesting schedule, releasing tokens early.

- Payout: Contest reward
- Severity: medium
- Program: SecondSwap
- Credited: sl1
- Disclosed: 2025-02-18
- Write-up quality: 6/10
- Original: https://code4rena.com/reports/2024-12-secondswap#m-17
- Library page: https://bugbountylibrary.com/r/c4%3A2024-12-secondswap%3AM-17
- Tags: domain:web3 impact:dos impact:integrity kind:contest platform:code4rena sev:medium tech:solidity technique:source-review vuln:accounting-error vuln:dos

**Target:** SecondSwap_StepVesting.sol
**Root cause:** stepDuration = (_endTime - _startTime) / _numOfSteps truncates; small durations with many steps yield 0 (division-by-zero in claimable) or a shortened effective schedule.
**Steps:**
1. Deploy vesting via `deployVesting(token, startTime, startTime+7884000, 1000000, "1")` so stepDuration = 7.884 -> 7
2. Create vesting for alice of 10000e18
3. Warp to `startTime + 1000000*7` (884000s early)
4. Call `claim()`; alice receives full 10000e18 early
5. For zero case: deploy with startTime=1733902691, endTime=1733902692, steps=24 -> stepDuration=0; `claim()` reverts on `elapsedTime / stepDuration`
**How found:** Warden reasoned about extreme sponsor-flagged inputs (duration/cycle extremes) and traced the division in stepDuration through claimable() to find truncation and divide-by-zero.
**Exploitation:** Token issuer misconfigures step count/duration; beneficiaries claim full allocation before schedule end, or claims revert permanently when stepDuration is 0.
**Insight:** When a schedule divides total duration by a step count, test non-divisible and near-zero quotients: truncation both shortens the effective schedule and can produce a zero divisor in downstream elapsed/step math.
