Skip to content

Commit

Permalink
docs(SDAO): add reasoning for safe unchecked blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
amusingaxl committed Sep 25, 2023
1 parent 775db2d commit f87cdb1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/SDAO.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit f87cdb1

Please sign in to comment.