Skip to content

Commit

Permalink
comment improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
dianakocsis committed Aug 30, 2024
1 parent 4e12ba3 commit 271348a
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 15 deletions.
3 changes: 1 addition & 2 deletions src/PositionManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
_;
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/base/DeltaResolver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions src/base/EIP712_v4.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions src/base/UnorderedNonce.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 6 additions & 6 deletions src/interfaces/IQuoter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/ActionConstants.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit 271348a

Please sign in to comment.