Skip to content

Commit

Permalink
spearbit comments
Browse files Browse the repository at this point in the history
  • Loading branch information
snreynolds committed Nov 18, 2024
1 parent 4b5ad0c commit 2b337de
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/PositionManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ contract PositionManager is
_getFullCredit(poolKey.currency1)
);

_mint(poolKey, tickLower, tickUpper, uint256(liquidity), amount0Max, amount1Max, owner, hookData);
_mint(poolKey, tickLower, tickUpper, liquidity, amount0Max, amount1Max, owner, hookData);
}

/// @dev this is overloaded with ERC721Permit_v4._burn
Expand Down
33 changes: 17 additions & 16 deletions src/libraries/Actions.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,29 @@ library Actions {
uint256 constant SWAP_EXACT_OUT_SINGLE = 0x08;
uint256 constant SWAP_EXACT_OUT = 0x09;
// donate
uint256 constant DONATE = 0x10;
uint256 constant DONATE = 0x0a;

// closing deltas on the pool manager
// settling
uint256 constant SETTLE = 0x11;
uint256 constant SETTLE_ALL = 0x12;
uint256 constant SETTLE_PAIR = 0x13;
uint256 constant SETTLE = 0x0b;
uint256 constant SETTLE_ALL = 0x0c;
uint256 constant SETTLE_PAIR = 0x0d;
// taking
uint256 constant TAKE = 0x14;
uint256 constant TAKE_ALL = 0x15;
uint256 constant TAKE_PORTION = 0x16;
uint256 constant TAKE_PAIR = 0x17;
uint256 constant TAKE = 0x0e;
uint256 constant TAKE_ALL = 0x0f;

uint256 constant SETTLE_TAKE_PAIR = 0x18;
uint256 constant CLOSE_CURRENCY = 0x19;
uint256 constant CLEAR_OR_TAKE = 0x20;
uint256 constant SWEEP = 0x21;
uint256 constant TAKE_PORTION = 0x10;
uint256 constant TAKE_PAIR = 0x11;

uint256 constant WRAP = 0x22;
uint256 constant UNWRAP = 0x23;
uint256 constant SETTLE_TAKE_PAIR = 0x12;
uint256 constant CLOSE_CURRENCY = 0x13;
uint256 constant CLEAR_OR_TAKE = 0x14;
uint256 constant SWEEP = 0x15;

uint256 constant WRAP = 0x16;
uint256 constant UNWRAP = 0x17;

// minting/burning 6909s to close deltas
uint256 constant MINT_6909 = 0x24;
uint256 constant BURN_6909 = 0x25;
uint256 constant MINT_6909 = 0x18;
uint256 constant BURN_6909 = 0x19;
}
14 changes: 9 additions & 5 deletions src/libraries/LiquidityAmounts.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ library LiquidityAmounts {
pure
returns (uint128 liquidity)
{
if (sqrtPriceAX96 > sqrtPriceBX96) (sqrtPriceAX96, sqrtPriceBX96) = (sqrtPriceBX96, sqrtPriceAX96);
uint256 intermediate = FullMath.mulDiv(sqrtPriceAX96, sqrtPriceBX96, FixedPoint96.Q96);
return FullMath.mulDiv(amount0, intermediate, sqrtPriceBX96 - sqrtPriceAX96).toUint128();
unchecked {
if (sqrtPriceAX96 > sqrtPriceBX96) (sqrtPriceAX96, sqrtPriceBX96) = (sqrtPriceBX96, sqrtPriceAX96);
uint256 intermediate = FullMath.mulDiv(sqrtPriceAX96, sqrtPriceBX96, FixedPoint96.Q96);
return FullMath.mulDiv(amount0, intermediate, sqrtPriceBX96 - sqrtPriceAX96).toUint128();
}
}

/// @notice Computes the amount of liquidity received for a given amount of token1 and price range
Expand All @@ -36,8 +38,10 @@ library LiquidityAmounts {
pure
returns (uint128 liquidity)
{
if (sqrtPriceAX96 > sqrtPriceBX96) (sqrtPriceAX96, sqrtPriceBX96) = (sqrtPriceBX96, sqrtPriceAX96);
return FullMath.mulDiv(amount1, FixedPoint96.Q96, sqrtPriceBX96 - sqrtPriceAX96).toUint128();
unchecked {
if (sqrtPriceAX96 > sqrtPriceBX96) (sqrtPriceAX96, sqrtPriceBX96) = (sqrtPriceBX96, sqrtPriceAX96);
return FullMath.mulDiv(amount1, FixedPoint96.Q96, sqrtPriceBX96 - sqrtPriceAX96).toUint128();
}
}

/// @notice Computes the maximum amount of liquidity received for a given amount of token0, token1, the current
Expand Down

0 comments on commit 2b337de

Please sign in to comment.