From 271348a7c73f117cf9bff7494f8c5e86d4ade7c4 Mon Sep 17 00:00:00 2001 From: dianakocsis Date: Fri, 30 Aug 2024 17:09:58 -0400 Subject: [PATCH] comment improvements --- src/PositionManager.sol | 3 +-- src/base/DeltaResolver.sol | 4 ++-- src/base/EIP712_v4.sol | 4 ++-- src/base/UnorderedNonce.sol | 4 ++-- src/interfaces/IQuoter.sol | 12 ++++++------ src/libraries/ActionConstants.sol | 2 +- 6 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/PositionManager.sol b/src/PositionManager.sol index ba210570..aa5a1b65 100644 --- a/src/PositionManager.sol +++ b/src/PositionManager.sol @@ -142,7 +142,7 @@ contract PositionManager is /// @param caller The address of the caller /// @param tokenId the unique identifier of the ERC721 token /// @dev either msg.sender or _msgSender() is passed in as the caller - /// _msgSender() should ONLY be used if this is being called from within the unlockCallback + /// msgSender() should ONLY be used if this is called from within the unlockCallback, unless the codepath has reentrancy protection modifier onlyIfApproved(address caller, uint256 tokenId) override { if (!_isApprovedOrOwner(caller, tokenId)) revert NotApproved(caller); _; @@ -301,7 +301,6 @@ contract PositionManager is } _mint(owner, tokenId); - // _beforeModify is not called here because the tokenId is newly minted (BalanceDelta liquidityDelta, BalanceDelta feesAccrued) = _modifyLiquidity(config, liquidity.toInt256(), bytes32(tokenId), hookData); // Slippage checks should be done on the principal liquidityDelta which is the liquidityDelta - feesAccrued diff --git a/src/base/DeltaResolver.sol b/src/base/DeltaResolver.sol index b8432c3c..69231b82 100644 --- a/src/base/DeltaResolver.sol +++ b/src/base/DeltaResolver.sol @@ -52,7 +52,7 @@ abstract contract DeltaResolver is ImmutableState { /// @return amount The amount owed by this contract as a uint256 function _getFullDebt(Currency currency) internal view returns (uint256 amount) { int256 _amount = poolManager.currencyDelta(address(this), currency); - // If the amount is negative, it should be settled not taken. + // If the amount is negative, it should be taken not settled. if (_amount > 0) revert DeltaNotNegative(currency); amount = uint256(-_amount); } @@ -62,7 +62,7 @@ abstract contract DeltaResolver is ImmutableState { /// @return amount The amount owed to this contract as a uint256 function _getFullCredit(Currency currency) internal view returns (uint256 amount) { int256 _amount = poolManager.currencyDelta(address(this), currency); - // If the amount is negative, it should be taken not settled for. + // If the amount is positive, it should be settled not taken. if (_amount < 0) revert DeltaNotPositive(currency); amount = uint256(_amount); } diff --git a/src/base/EIP712_v4.sol b/src/base/EIP712_v4.sol index 66b7070a..4106043c 100644 --- a/src/base/EIP712_v4.sol +++ b/src/base/EIP712_v4.sol @@ -6,8 +6,8 @@ import {IEIP712_v4} from "../interfaces/IEIP712_v4.sol"; /// @notice Generic EIP712 implementation /// @dev Maintains cross-chain replay protection in the event of a fork /// @dev Should not be delegatecall'd because DOMAIN_SEPARATOR returns the cached hash and does not recompute with the delegatecallers address -/// @dev Reference: https://github.com/Uniswap/permit2/blob/main/src/EIP712.sol -/// @dev Reference: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/EIP712.sol +/// @dev Reference: https://github.com/Uniswap/permit2/blob/3f17e8db813189a03950dc7fc8382524a095c053/src/EIP712.sol +/// @dev Reference: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/7bd2b2aaf68c21277097166a9a51eb72ae239b34/contracts/utils/cryptography/EIP712.sol contract EIP712_v4 is IEIP712_v4 { // Cache the domain separator as an immutable value, but also store the chain id that it // corresponds to, in order to invalidate the cached domain separator if the chain id changes. diff --git a/src/base/UnorderedNonce.sol b/src/base/UnorderedNonce.sol index 75a34fe4..13feb108 100644 --- a/src/base/UnorderedNonce.sol +++ b/src/base/UnorderedNonce.sol @@ -10,9 +10,9 @@ contract UnorderedNonce { /// @dev word is at most type(uint248).max mapping(address owner => mapping(uint256 word => uint256 bitmap)) public nonces; - /// @notice Consume a nonce, reverting if its already been used + /// @notice Consume a nonce, reverting if it has already been used /// @param owner address, the owner/signer of the nonce - /// @param nonce uint256, the nonce to consume. the top 248 bits are the word, the bottom 8 bits indicate the bit position + /// @param nonce uint256, the nonce to consume. The top 248 bits are the word, the bottom 8 bits indicate the bit position function _useUnorderedNonce(address owner, uint256 nonce) internal { uint256 wordPos = nonce >> 8; uint256 bitPos = uint8(nonce); diff --git a/src/interfaces/IQuoter.sol b/src/interfaces/IQuoter.sol index c1fcfb63..57db3778 100644 --- a/src/interfaces/IQuoter.sol +++ b/src/interfaces/IQuoter.sol @@ -6,7 +6,7 @@ import {Currency} from "@uniswap/v4-core/src/types/Currency.sol"; import {PathKey} from "../libraries/PathKey.sol"; /// @title Quoter Interface -/// @notice Supports quoting the delta amounts from exact input or exact output swaps. +/// @notice Supports quoting the delta amounts for exact input or exact output swaps. /// @notice For each pool also tells you the number of initialized ticks loaded and the sqrt price of the pool after the swap. /// @dev These functions are not marked view because they rely on calling non-view functions and reverting /// to compute the result. They are also not gas efficient and should not be called on-chain. @@ -38,7 +38,7 @@ interface IQuoter { } /// @notice Returns the delta amounts for a given exact input swap of a single pool - /// @param params The params for the quote, encoded as `QuoteExactInputSingleParams` + /// @param params The params for the quote, encoded as `QuoteExactSingleParams` /// poolKey The key for identifying a V4 pool /// zeroForOne If the swap is from currency0 to currency1 /// exactAmount The desired input amount @@ -52,7 +52,7 @@ interface IQuoter { returns (int128[] memory deltaAmounts, uint160 sqrtPriceX96After, uint32 initializedTicksLoaded); /// @notice Returns the delta amounts along the swap path for a given exact input swap - /// @param params the params for the quote, encoded as 'QuoteExactInputParams' + /// @param params the params for the quote, encoded as 'QuoteExactParams' /// currencyIn The input currency of the swap /// path The path of the swap encoded as PathKeys that contains currency, fee, tickSpacing, and hook info /// exactAmount The desired input amount @@ -68,10 +68,10 @@ interface IQuoter { ); /// @notice Returns the delta amounts for a given exact output swap of a single pool - /// @param params The params for the quote, encoded as `QuoteExactOutputSingleParams` + /// @param params The params for the quote, encoded as `QuoteExactSingleParams` /// poolKey The key for identifying a V4 pool /// zeroForOne If the swap is from currency0 to currency1 - /// exactAmount The desired input amount + /// exactAmount The desired output amount /// sqrtPriceLimitX96 The price limit of the pool that cannot be exceeded by the swap /// hookData arbitrary hookData to pass into the associated hooks /// @return deltaAmounts Delta amounts resulted from the swap @@ -82,7 +82,7 @@ interface IQuoter { returns (int128[] memory deltaAmounts, uint160 sqrtPriceX96After, uint32 initializedTicksLoaded); /// @notice Returns the delta amounts along the swap path for a given exact output swap - /// @param params the params for the quote, encoded as 'QuoteExactOutputParams' + /// @param params the params for the quote, encoded as 'QuoteExactParams' /// currencyOut The output currency of the swap /// path The path of the swap encoded as PathKeys that contains currency, fee, tickSpacing, and hook info /// exactAmount The desired output amount diff --git a/src/libraries/ActionConstants.sol b/src/libraries/ActionConstants.sol index bb878540..e371f549 100644 --- a/src/libraries/ActionConstants.sol +++ b/src/libraries/ActionConstants.sol @@ -9,7 +9,7 @@ library ActionConstants { /// This value is equivalent to 1<<255, i.e. a singular 1 in the most significant bit. uint256 internal constant CONTRACT_BALANCE = 0x8000000000000000000000000000000000000000000000000000000000000000; - /// @notice used to signal that the recipient of an action should be the msgSender of address(this) + /// @notice used to signal that the recipient of an action should be the msgSender or address(this) address internal constant MSG_SENDER = address(1); address internal constant ADDRESS_THIS = address(2); }