Skip to content

Commit

Permalink
Internal audit1 (#15)
Browse files Browse the repository at this point in the history
* refactor: [internal-s1] delete subscriber before notifyUnsubscribe

* refactor: [internal-s2] replace encodeWithSelector with encodeCall

* refactor: [internal-s3] code styles

* feat: [internal-s4] support revoke nonce

* chore: add missing
  • Loading branch information
chefburger authored Sep 9, 2024
1 parent d4ad2d2 commit 5bc5fb5
Show file tree
Hide file tree
Showing 71 changed files with 150 additions and 91 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
867056
867055
Original file line number Diff line number Diff line change
@@ -1 +1 @@
795924
795990
Original file line number Diff line number Diff line change
@@ -1 +1 @@
680323
680367
Original file line number Diff line number Diff line change
@@ -1 +1 @@
752123
752167
Original file line number Diff line number Diff line change
@@ -1 +1 @@
846293
846359
Original file line number Diff line number Diff line change
@@ -1 +1 @@
733247
733291
Original file line number Diff line number Diff line change
@@ -1 +1 @@
802534
802578
Original file line number Diff line number Diff line change
@@ -1 +1 @@
795936
796002
Original file line number Diff line number Diff line change
@@ -1 +1 @@
680335
680379
Original file line number Diff line number Diff line change
@@ -1 +1 @@
752123
752167
Original file line number Diff line number Diff line change
@@ -1 +1 @@
844275
844341
Original file line number Diff line number Diff line change
@@ -1 +1 @@
731229
731273
Original file line number Diff line number Diff line change
@@ -1 +1 @@
800516
800560
2 changes: 1 addition & 1 deletion .forge-snapshots/CLPositionManager_burn_empty.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
57949
57984
2 changes: 1 addition & 1 deletion .forge-snapshots/CLPositionManager_burn_empty_native.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
57757
57792
Original file line number Diff line number Diff line change
@@ -1 +1 @@
177568
177604
Original file line number Diff line number Diff line change
@@ -1 +1 @@
177109
177144
Original file line number Diff line number Diff line change
@@ -1 +1 @@
184624
184659
Original file line number Diff line number Diff line change
@@ -1 +1 @@
184164
184200
2 changes: 1 addition & 1 deletion .forge-snapshots/CLPositionManager_collect_native.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
200166
200210
2 changes: 1 addition & 1 deletion .forge-snapshots/CLPositionManager_collect_sameRange.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
208985
209029
2 changes: 1 addition & 1 deletion .forge-snapshots/CLPositionManager_collect_withClose.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
208985
209029
Original file line number Diff line number Diff line change
@@ -1 +1 @@
208423
208467
Original file line number Diff line number Diff line change
@@ -1 +1 @@
165242
165286
Original file line number Diff line number Diff line change
@@ -1 +1 @@
174061
174105
Original file line number Diff line number Diff line change
@@ -1 +1 @@
173499
173543
2 changes: 1 addition & 1 deletion .forge-snapshots/CLPositionManager_decrease_burnEmpty.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
189024
189060
Original file line number Diff line number Diff line change
@@ -1 +1 @@
181777
181812
Original file line number Diff line number Diff line change
@@ -1 +1 @@
186730
186774
2 changes: 1 addition & 1 deletion .forge-snapshots/CLPositionManager_decrease_take_take.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
174678
174722
Original file line number Diff line number Diff line change
@@ -1 +1 @@
213500
213544
Original file line number Diff line number Diff line change
@@ -1 +1 @@
212560
212604
Original file line number Diff line number Diff line change
@@ -1 +1 @@
195082
195126
Original file line number Diff line number Diff line change
@@ -1 +1 @@
158398
158442
Original file line number Diff line number Diff line change
@@ -1 +1 @@
231569
231613
Original file line number Diff line number Diff line change
@@ -1 +1 @@
202405
202449
2 changes: 1 addition & 1 deletion .forge-snapshots/CLPositionManager_mint_native.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
587542
587586
Original file line number Diff line number Diff line change
@@ -1 +1 @@
596018
596062
Original file line number Diff line number Diff line change
@@ -1 +1 @@
595362
595406
Original file line number Diff line number Diff line change
@@ -1 +1 @@
442411
442455
Original file line number Diff line number Diff line change
@@ -1 +1 @@
442848
442892
2 changes: 1 addition & 1 deletion .forge-snapshots/CLPositionManager_mint_sameRange.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
351658
351702
Original file line number Diff line number Diff line change
@@ -1 +1 @@
641844
641888
Original file line number Diff line number Diff line change
@@ -1 +1 @@
448101
448145
2 changes: 1 addition & 1 deletion .forge-snapshots/CLPositionManager_mint_withClose.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
642960
643004
Original file line number Diff line number Diff line change
@@ -1 +1 @@
642162
642206
Original file line number Diff line number Diff line change
@@ -1 +1 @@
702482
702570
2 changes: 1 addition & 1 deletion .forge-snapshots/CLPositionManager_permit.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
79188
79210
Original file line number Diff line number Diff line change
@@ -1 +1 @@
62088
62110
2 changes: 1 addition & 1 deletion .forge-snapshots/CLPositionManager_permit_twice.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
44988
45010
2 changes: 1 addition & 1 deletion src/V4Router.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {ICLPoolManager} from "pancake-v4-core/src/pool-cl/interfaces/ICLPoolMana
import {IBinPoolManager} from "pancake-v4-core/src/pool-bin/interfaces/IBinPoolManager.sol";
import {BalanceDelta} from "pancake-v4-core/src/types/BalanceDelta.sol";
import {PoolKey} from "pancake-v4-core/src/types/PoolKey.sol";
import {Currency, CurrencyLibrary} from "pancake-v4-core/src/types/Currency.sol";
import {Currency} from "pancake-v4-core/src/types/Currency.sol";
import {BipsLibrary} from "./libraries/BipsLibrary.sol";
import {CalldataDecoder} from "./libraries/CalldataDecoder.sol";
import {IV4Router} from "./interfaces/IV4Router.sol";
Expand Down
1 change: 0 additions & 1 deletion src/base/BaseActionsRouter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ pragma solidity ^0.8.24;
import {IVault} from "pancake-v4-core/src/interfaces/IVault.sol";
import {SafeCallback} from "./SafeCallback.sol";
import {CalldataDecoder} from "../libraries/CalldataDecoder.sol";
import {Actions} from "../libraries/Actions.sol";
import {ActionConstants} from "../libraries/ActionConstants.sol";

/// @notice Abstract contract for performing a combination of actions on Pancakeswap v4.
Expand Down
1 change: 0 additions & 1 deletion src/base/DeltaResolver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
pragma solidity ^0.8.24;

import {Currency} from "pancake-v4-core/src/types/Currency.sol";
import {IVault} from "pancake-v4-core/src/interfaces/IVault.sol";
import {ImmutableState} from "./ImmutableState.sol";
import {ActionConstants} from "../libraries/ActionConstants.sol";

Expand Down
3 changes: 0 additions & 3 deletions src/interfaces/IPositionManager.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.24;

import {PoolKey} from "pancake-v4-core/src/types/PoolKey.sol";
import {Currency} from "pancake-v4-core/src/types/Currency.sol";

interface IPositionManager {
error DeadlinePassed();
error InvalidTokenID();
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/CalldataDecoder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ library CalldataDecoder {
/// @notice equivalent to SliceOutOfBounds.selector
bytes4 constant SLICE_ERROR_SELECTOR = 0x3b99b53d;

/// @dev equivalent to: abi.decode(params, (uint256[], bytes[])) in calldata
/// @dev equivalent to: abi.decode(params, (bytes, bytes[])) in calldata
function decodeActionsRouterParams(bytes calldata _bytes)
internal
pure
Expand Down
4 changes: 2 additions & 2 deletions src/pool-bin/interfaces/IBinQuoter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ interface IBinQuoter is IQuoter {
/// hookData arbitrary hookData to pass into the associated hooks
/// @return deltaAmounts Delta amounts resulted from the swap
/// @return activeIdAfter The activeId of the pool after the swap
function quoteExactInputSingle(QuoteExactSingleParams calldata params)
function quoteExactInputSingle(QuoteExactSingleParams memory params)
external
returns (int128[] memory deltaAmounts, uint24 activeIdAfter);

Expand All @@ -65,7 +65,7 @@ interface IBinQuoter is IQuoter {
/// hookData arbitrary hookData to pass into the associated hooks
/// @return deltaAmounts Delta amounts resulted from the swap
/// @return activeIdAfter The activeId of the pool after the swap
function quoteExactOutputSingle(QuoteExactSingleParams calldata params)
function quoteExactOutputSingle(QuoteExactSingleParams memory params)
external
returns (int128[] memory deltaAmounts, uint24 activeIdAfter);

Expand Down
8 changes: 4 additions & 4 deletions src/pool-bin/lens/BinQuoter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ contract BinQuoter is Quoter, IBinQuoter {
override
returns (int128[] memory deltaAmounts, uint24 activeIdAfter)
{
try vault.lock(abi.encodeWithSelector(this._quoteExactInputSingle.selector, params)) {}
try vault.lock(abi.encodeCall(this._quoteExactInputSingle, (params))) {}
catch (bytes memory reason) {
return _handleRevertSingle(reason);
}
Expand All @@ -47,7 +47,7 @@ contract BinQuoter is Quoter, IBinQuoter {
override
returns (int128[] memory deltaAmounts, uint24[] memory activeIdAfterList)
{
try vault.lock(abi.encodeWithSelector(this._quoteExactInput.selector, params)) {}
try vault.lock(abi.encodeCall(this._quoteExactInput, (params))) {}
catch (bytes memory reason) {
return _handleRevert(reason);
}
Expand All @@ -59,7 +59,7 @@ contract BinQuoter is Quoter, IBinQuoter {
override
returns (int128[] memory deltaAmounts, uint24 activeIdAfter)
{
try vault.lock(abi.encodeWithSelector(this._quoteExactOutputSingle.selector, params)) {}
try vault.lock(abi.encodeCall(this._quoteExactOutputSingle, (params))) {}
catch (bytes memory reason) {
delete amountOutCached;
return _handleRevertSingle(reason);
Expand All @@ -72,7 +72,7 @@ contract BinQuoter is Quoter, IBinQuoter {
override
returns (int128[] memory deltaAmounts, uint24[] memory activeIdAfterList)
{
try vault.lock(abi.encodeWithSelector(this._quoteExactOutput.selector, params)) {}
try vault.lock(abi.encodeCall(this._quoteExactOutput, (params))) {}
catch (bytes memory reason) {
return _handleRevert(reason);
}
Expand Down
2 changes: 2 additions & 0 deletions src/pool-cl/CLPositionManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ contract CLPositionManager is

ICLPoolManager public immutable override clPoolManager;

/// @inheritdoc ICLPositionManager
/// @dev The ID of the next token that will be minted. Skips 0
uint256 public nextTokenId = 1;

Expand Down Expand Up @@ -165,6 +166,7 @@ contract CLPositionManager is
_executeActionsWithoutLock(actions, params);
}

/// @inheritdoc BaseActionsRouter
function msgSender() public view override returns (address) {
return _getLocker();
}
Expand Down
Loading

0 comments on commit 5bc5fb5

Please sign in to comment.