Skip to content

Commit

Permalink
hexens audit feedback (#81)
Browse files Browse the repository at this point in the history
* feat: bump infinity-core

* [fh-p1] typo error

* feat: set version at v0.3.0

* feat: updated infinity-core dependency
  • Loading branch information
ChefMist authored Feb 14, 2025
1 parent 481650d commit 4452b48
Show file tree
Hide file tree
Showing 13 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: stable
version: v0.3.0

- name: Run tests
run: forge test --isolate -vvv
Expand Down
6 changes: 3 additions & 3 deletions src/MixedQuoter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ contract MixedQuoter is IMixedQuoter, IPancakeV3SwapCallback, Multicall {
} else if (action == MixedQuoterActions.INFI_CL_EXACT_INPUT_SINGLE) {
QuoteMixedInfiExactInputSingleParams memory clParams =
abi.decode(params[actionIndex], (QuoteMixedInfiExactInputSingleParams));
(tokenIn, tokenOut) = convertWETHToInfiNativeCurency(clParams.poolKey, tokenIn, tokenOut);
(tokenIn, tokenOut) = convertWETHToInfiNativeCurrency(clParams.poolKey, tokenIn, tokenOut);
bool zeroForOne = tokenIn < tokenOut;
checkInfiPoolKeyCurrency(clParams.poolKey, zeroForOne, tokenIn, tokenOut);

Expand Down Expand Up @@ -342,7 +342,7 @@ contract MixedQuoter is IMixedQuoter, IPancakeV3SwapCallback, Multicall {
} else if (action == MixedQuoterActions.INFI_BIN_EXACT_INPUT_SINGLE) {
QuoteMixedInfiExactInputSingleParams memory binParams =
abi.decode(params[actionIndex], (QuoteMixedInfiExactInputSingleParams));
(tokenIn, tokenOut) = convertWETHToInfiNativeCurency(binParams.poolKey, tokenIn, tokenOut);
(tokenIn, tokenOut) = convertWETHToInfiNativeCurrency(binParams.poolKey, tokenIn, tokenOut);
bool zeroForOne = tokenIn < tokenOut;
checkInfiPoolKeyCurrency(binParams.poolKey, zeroForOne, tokenIn, tokenOut);

Expand Down Expand Up @@ -452,7 +452,7 @@ contract MixedQuoter is IMixedQuoter, IPancakeV3SwapCallback, Multicall {
/// @notice Convert WETH to native currency for infinity pools
/// @dev for example, quote route are v3 WETH pool[token0, WETH] and infinity native pool[NATIVE,token1]
/// paths is [token0, WETH, token1], we need to convert WETH to NATIVE when quote infinity pool
function convertWETHToInfiNativeCurency(PoolKey memory poolKey, address tokenIn, address tokenOut)
function convertWETHToInfiNativeCurrency(PoolKey memory poolKey, address tokenIn, address tokenOut)
private
view
returns (address, address)
Expand Down
2 changes: 1 addition & 1 deletion src/base/BaseActionsRouter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ abstract contract BaseActionsRouter is SafeCallback {
/// @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` shouldnt be used, as this will be the vault contract that calls `lockAcquired`
/// `msg.sender` shouldn't be used, as this will be the vault contract that calls `lockAcquired`
/// If using ReentrancyLock.sol, this function can return _getLocker()
function msgSender() public view virtual returns (address);

Expand Down
4 changes: 2 additions & 2 deletions src/libraries/CalldataDecoder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ library CalldataDecoder {
expectedOffset := add(expectedOffset, length)
}

// if the data encoding was invalid, or the provided bytes string isnt as long as the encoding says, revert
// if the data encoding was invalid, or the provided bytes string isn't as long as the encoding says, revert
if or(invalidData, lt(add(_bytes.length, _bytes.offset), add(params.offset, expectedOffset))) {
mstore(0, SLICE_ERROR_SELECTOR)
revert(0x1c, 4)
Expand Down Expand Up @@ -204,7 +204,7 @@ library CalldataDecoder {
res.length := length
res.offset := offset

// if the provided bytes string isnt as long as the encoding says, revert
// if the provided bytes string isn't as long as the encoding says, revert
if lt(add(_bytes.length, _bytes.offset), add(length, offset)) {
mstore(0, SLICE_ERROR_SELECTOR)
revert(0x1c, 4)
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/Planner.sol
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ library Planner {
returns (bytes memory)
{
if (takeRecipient == ActionConstants.MSG_SENDER) {
// blindly settling and taking all, without slippage checks, isnt recommended in prod
// blindly settling and taking all, without slippage checks, isn't recommended in prod
plan = plan.add(Actions.SETTLE_ALL, abi.encode(inputCurrency, type(uint256).max));
plan = plan.add(Actions.TAKE_ALL, abi.encode(outputCurrency, 0));
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/QuoterRevert.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ library QuoterRevert {
/// @notice validates whether a revert reason is a valid swap quote or not
/// if valid, it decodes the quote to return. Otherwise it reverts.
function parseQuoteAmount(bytes memory reason) internal pure returns (uint256 quoteAmount) {
// If the error doesnt start with QuoteSwap, we know this isnt a valid quote to parse
// If the error doesnt start with QuoteSwap, we know this isn't a valid quote to parse
// Instead it is another revert that was triggered somewhere in the simulation
if (reason.parseSelector() != QuoteSwap.selector) {
revert UnexpectedRevertBytes(reason);
Expand Down
4 changes: 2 additions & 2 deletions src/pool-bin/BinMigrator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ contract BinMigrator is IBinMigrator, BaseMigrator, ReentrancyLock {
);
(uint256 amount0Received, uint256 amount1Received) = withdrawLiquidityFromV2(v2PoolParams, shouldReversePair);

/// @notice if user mannually specify the price range, they might need to send extra token
/// @notice if user manually specify the price range, they might need to send extra token
batchAndNormalizeTokens(
infiPoolParams.poolKey.currency0, infiPoolParams.poolKey.currency1, extraAmount0, extraAmount1
);
Expand Down Expand Up @@ -84,7 +84,7 @@ contract BinMigrator is IBinMigrator, BaseMigrator, ReentrancyLock {
);
(uint256 amount0Received, uint256 amount1Received) = withdrawLiquidityFromV3(v3PoolParams, shouldReversePair);

/// @notice if user mannually specify the price range, they need to send extra token
/// @notice if user manually specify the price range, they need to send extra token
batchAndNormalizeTokens(
infiPoolParams.poolKey.currency0, infiPoolParams.poolKey.currency1, extraAmount0, extraAmount1
);
Expand Down
2 changes: 1 addition & 1 deletion src/pool-bin/BinPositionManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ contract BinPositionManager is
}

if (activeIdDesired > type(uint24).max || idSlippage > type(uint24).max) {
revert AddLiquidityInputActiveIdMismath();
revert AddLiquidityInputActiveIdMismatch();
}

/// @dev Checks if the activeId is within slippage before calling mint. If user mint to activeId and there
Expand Down
6 changes: 3 additions & 3 deletions src/pool-bin/interfaces/IBinPositionManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {IPositionManager} from "../../interfaces/IPositionManager.sol";
interface IBinPositionManager is IPositionManager {
error IdOverflows(int256);
error IdSlippageCaught(uint256 activeIdDesired, uint256 idSlippage, uint24 activeId);
error AddLiquidityInputActiveIdMismath();
error AddLiquidityInputActiveIdMismatch();

/// @notice BinAddLiquidityParams
/// - amount0: Amount to send for token0
Expand Down Expand Up @@ -40,8 +40,8 @@ interface IBinPositionManager is IPositionManager {
}

/// @notice BinRemoveLiquidityParams
/// - amount0Min: Min amount to recieve for token0
/// - amount1Min: Min amount to recieve for token1
/// - amount0Min: Min amount to receive for token0
/// - amount1Min: Min amount to receive for token1
/// - ids: List of bin ids to remove liquidity
/// - amounts: List of share amount to remove for each bin
/// - from: Address of NFT holder to burn the NFT
Expand Down
4 changes: 2 additions & 2 deletions src/pool-cl/CLMigrator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ contract CLMigrator is ICLMigrator, BaseMigrator, ReentrancyLock {

(uint256 amount0Received, uint256 amount1Received) = withdrawLiquidityFromV2(v2PoolParams, shouldReversePair);

/// @notice if user mannually specify the price range, they might need to send extra token
/// @notice if user manually specify the price range, they might need to send extra token
batchAndNormalizeTokens(
infiPoolParams.poolKey.currency0, infiPoolParams.poolKey.currency1, extraAmount0, extraAmount1
);
Expand Down Expand Up @@ -82,7 +82,7 @@ contract CLMigrator is ICLMigrator, BaseMigrator, ReentrancyLock {
);
(uint256 amount0Received, uint256 amount1Received) = withdrawLiquidityFromV3(v3PoolParams, shouldReversePair);

/// @notice if user mannually specify the price range, they need to send extra token
/// @notice if user manually specify the price range, they need to send extra token
batchAndNormalizeTokens(
infiPoolParams.poolKey.currency0, infiPoolParams.poolKey.currency1, extraAmount0, extraAmount1
);
Expand Down
4 changes: 2 additions & 2 deletions test/pool-bin/BinPositionManager_ModifyLiquidites.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,14 @@ contract BinPositionManager_ModifyLiquidityTest is BinLiquidityHelper, TokenFixt
param = _getAddParams(key1, binIds, 1 ether, 1 ether, activeId, alice);
param.activeIdDesired = input;
payload = Planner.init().add(Actions.BIN_ADD_LIQUIDITY, abi.encode(param)).encode();
vm.expectRevert(abi.encodeWithSelector(IBinPositionManager.AddLiquidityInputActiveIdMismath.selector));
vm.expectRevert(abi.encodeWithSelector(IBinPositionManager.AddLiquidityInputActiveIdMismatch.selector));
binPm.modifyLiquidities(payload, _deadline);

// active id normal, but slippage above type(uint24).max
param = _getAddParams(key1, binIds, 1 ether, 1 ether, activeId, alice);
param.idSlippage = input;
payload = Planner.init().add(Actions.BIN_ADD_LIQUIDITY, abi.encode(param)).encode();
vm.expectRevert(abi.encodeWithSelector(IBinPositionManager.AddLiquidityInputActiveIdMismath.selector));
vm.expectRevert(abi.encodeWithSelector(IBinPositionManager.AddLiquidityInputActiveIdMismatch.selector));
binPm.modifyLiquidities(payload, _deadline);
}

Expand Down
2 changes: 1 addition & 1 deletion test/pool-cl/position-managers/CLPositionManager.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ contract PositionManagerTest is Test, PosmTestSetup, LiquidityFuzzers {
uint256 liquidity = lpm.getPositionLiquidity(tokenId);
assertEq(liquidity, uint256(params.liquidityDelta) - decreaseLiquidityDelta);

// did not recieve tokens, as they were forfeited with CLEAR
// did not receive tokens, as they were forfeited with CLEAR
assertEq(currency0.balanceOfSelf(), balance0Before);
assertEq(currency1.balanceOfSelf(), balance1Before);
}
Expand Down

0 comments on commit 4452b48

Please sign in to comment.