From 1230032d5b411e344f7f01d5bbb67a2726174f53 Mon Sep 17 00:00:00 2001 From: atarpara Date: Mon, 31 Aug 2026 16:52:39 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=A5=A2=20Add=20notes=20to=20ERC20Votes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/tokens/ERC20Votes.sol | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/tokens/ERC20Votes.sol b/src/tokens/ERC20Votes.sol index d9cc37dad..0c09df1a6 100644 --- a/src/tokens/ERC20Votes.sol +++ b/src/tokens/ERC20Votes.sol @@ -250,7 +250,8 @@ abstract contract ERC20Votes is ERC20 { /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Returns the amount of voting units `delegator` has control over. - /// Override if you need a different formula. + /// Note: Overriding this function may compromise the internal vote accounting. + /// `ERC20Votes` assumes tokens map to voting units 1:1 and this is not easy to change. function _getVotingUnits(address delegator) internal view virtual returns (uint256) { return balanceOf(delegator); } @@ -265,6 +266,8 @@ abstract contract ERC20Votes is ERC20 { } /// @dev Used in `_afterTokenTransfer(address from, address to, uint256 amount)`. + /// Note: this moves the raw ERC20 `amount`, and on a mint or burn writes it to the total + /// supply checkpoint as well. See the NOTE on `_getVotingUnits`. function _transferVotingUnits(address from, address to, uint256 amount) internal virtual { if (from == address(0)) { _checkpointPushDiff(_ERC20_VOTES_MASTER_SLOT_SEED << 96, clock(), amount, true);