From f87cdb15813bcf4184850ea0a4317555eb8d3808 Mon Sep 17 00:00:00 2001 From: amusingaxl <112016538+amusingaxl@users.noreply.github.com> Date: Mon, 25 Sep 2023 20:12:06 -0300 Subject: [PATCH] docs(SDAO): add reasoning for safe `unchecked` blocks --- src/SDAO.sol | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/SDAO.sol b/src/SDAO.sol index 0aed767..3241892 100644 --- a/src/SDAO.sol +++ b/src/SDAO.sol @@ -199,6 +199,8 @@ contract SDAO { unchecked { balanceOf[msg.sender] = balance - value; + // Safe as the sum of all balances equals `totalSupply`; + // any overflow would have occurred already when increasing `totalSupply` balanceOf[to] += value; } @@ -233,6 +235,8 @@ contract SDAO { unchecked { balanceOf[from] = balance - value; + // Safe as the sum of all balances equals `totalSupply`; + // any overflow would have occurred already when increasing `totalSupply` balanceOf[to] += value; }