Skip to content

Commit

Permalink
Sb i62 (#323)
Browse files Browse the repository at this point in the history
* typos

* comment improvements

* format

* fix another typo

* fix more comments
  • Loading branch information
dianakocsis authored Aug 31, 2024
1 parent e15964c commit d254c02
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 23 deletions.
5 changes: 2 additions & 3 deletions src/PositionManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ contract PositionManager is
/// @notice Reverts if the caller is not the owner or approved for the ERC721 token
/// @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
/// @dev either msg.sender or msgSender() is passed in as the caller
/// 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
2 changes: 1 addition & 1 deletion src/base/BaseActionsRouter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ abstract contract BaseActionsRouter is SafeCallback {
/// @notice function to handle the parsing and execution of an action and its parameters
function _handleAction(uint256 action, bytes calldata params) internal virtual;

/// @notice function that returns address considered executer of the actions
/// @notice function that returns address considered executor of the actions
/// @dev The other context functions, _msgData and _msgValue, are not supported by this contract
/// In many contracts this will be the address that calls the initial entry point that calls `_executeActions`
/// `msg.sender` shouldn't be used, as this will be the v4 pool manager contract that calls `unlockCallback`
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 positive, 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 negative, 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/Notifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ abstract contract Notifier is INotifier {
onlyIfApproved(msg.sender, tokenId)
onlyValidConfig(tokenId, config)
{
// will revert below if the user already has a subcriber
// will revert below if the user already has a subscriber
_positionConfigs(tokenId).setSubscribe();
ISubscriber _subscriber = subscriber[tokenId];

Expand All @@ -52,7 +52,7 @@ abstract contract Notifier is INotifier {
bool success = _call(newSubscriber, abi.encodeCall(ISubscriber.notifySubscribe, (tokenId, config, data)));

if (!success) {
Wrap__SubsciptionReverted.selector.bubbleUpAndRevertWith(newSubscriber);
Wrap__SubscriptionReverted.selector.bubbleUpAndRevertWith(newSubscriber);
}

emit Subscribed(tokenId, newSubscriber);
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
2 changes: 1 addition & 1 deletion src/interfaces/INotifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {ISubscriber} from "./ISubscriber.sol";
/// @notice This interface is used to opt in to sending updates to external contracts about position modifications or transfers
interface INotifier {
/// @notice Wraps the revert message of the subscriber contract on a reverting subscription
error Wrap__SubsciptionReverted(address subscriber, bytes reason);
error Wrap__SubscriptionReverted(address subscriber, bytes reason);
/// @notice Wraps the revert message of the subscriber contract on a reverting modify liquidity notification
error Wrap__ModifyLiquidityNotificationReverted(address subscriber, bytes reason);
/// @notice Wraps the revert message of the subscriber contract on a reverting transfer notification
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
4 changes: 2 additions & 2 deletions src/lens/StateView.sol
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ contract StateView is ImmutableState {
}

/**
* @notice Retrieves total the liquidity of a pool.
* @notice Retrieves the total liquidity of a pool.
* @dev Corresponds to pools[poolId].liquidity
* @param poolId The ID of the pool.
* @return liquidity The liquidity of the pool.
Expand Down Expand Up @@ -161,7 +161,7 @@ contract StateView is ImmutableState {

/**
* @notice Retrieves the liquidity of a position.
* @dev Corresponds to pools[poolId].positions[positionId].liquidity. More gas efficient for just retrieiving liquidity as compared to getPositionInfo
* @dev Corresponds to pools[poolId].positions[positionId].liquidity. More gas efficient for just retrieving liquidity as compared to getPositionInfo
* @param poolId The ID of the pool.
* @param positionId The ID of the position.
* @return liquidity The liquidity of the position.
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);
}
2 changes: 1 addition & 1 deletion test/position-managers/PositionManager.notifier.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ contract PositionManagerNotifierTest is Test, PosmTestSetup, GasSnapshot {

vm.expectRevert(
abi.encodeWithSelector(
INotifier.Wrap__SubsciptionReverted.selector,
INotifier.Wrap__SubscriptionReverted.selector,
address(revertSubscriber),
abi.encodeWithSelector(MockRevertSubscriber.TestRevert.selector, "notifySubscribe")
)
Expand Down

0 comments on commit d254c02

Please sign in to comment.