Skip to content

Commit 8c3c2df

Browse files
committed
update docs
1 parent 14799bf commit 8c3c2df

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

contracts/token/ERC7984/extensions/ERC7984ERC20Wrapper.sol

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,11 @@ abstract contract ERC7984ERC20Wrapper is ERC7984, IERC1363Receiver {
151151
}
152152

153153
/**
154-
* @dev Returns the underlying balance divided by the {rate}, over-approximating the total supply of wrapped tokens.
154+
* @dev Returns the underlying balance divided by the {rate}, a value strictly greater than or equal to the
155+
* {ERC7984-confidentialTotalSupply}.
155156
*
156157
* NOTE: The return value of this function can be inflated by directly sending underlying tokens to the wrapper contract.
158+
* Reductions will lag compared to {confidentialTotalSupply} since it is updated on {unwrap} while
157159
*/
158160
function totalSupply() public view virtual returns (uint256) {
159161
return underlying().balanceOf(address(this)) / rate();
@@ -164,16 +166,22 @@ abstract contract ERC7984ERC20Wrapper is ERC7984, IERC1363Receiver {
164166
return type(uint64).max;
165167
}
166168

167-
/// @dev This function must revert if the new {ERC7984-confidentialTotalSupply} state is invalid.
168-
function _checkTotalSupply() internal virtual {
169+
/**
170+
* @dev This function must revert if the new {ERC7984-confidentialTotalSupply} is invalid (overflow occurred).
171+
*
172+
* NOTE: Overflow can be detected here since the wrapper holdings are non-confidential. In other cases, it may be impossible
173+
* to infer total supply overflow synchronously. This function may revert even if the {ERC7984-confidentialTotalSupply} did
174+
* not overflow.
175+
*/
176+
function _checkConfidentialTotalSupply() internal virtual {
169177
if (totalSupply() > maxTotalSupply()) {
170178
revert ERC7984TotalSupplyOverflow();
171179
}
172180
}
173181

174182
function _update(address from, address to, euint64 amount) internal virtual override returns (euint64) {
175183
if (from == address(0)) {
176-
_checkTotalSupply();
184+
_checkConfidentialTotalSupply();
177185
}
178186
return super._update(from, to, amount);
179187
}

0 commit comments

Comments
 (0)